Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the source code of it: <a href="https://github.com/django/django/blob/1.2.4/django/db/transaction.py#L286" rel="nofollow">https://github.com/django/django/blob/1.2.4/django/db/transaction.py#L286</a></p> <p>And <a href="https://github.com/django/django/blob/1.2.4/django/db/transaction.py#L46" rel="nofollow">enter_transaction_management</a> is as simple as putting new transaction handling mode on the thread stack.</p> <p>So, in your case, if <code>process_post_reply()</code> fails (i.e. exception occurs), then the transaction is rolled back in its entirety, and then the exception propagates upwards from <code>process_post()</code> as well but there is nothing to roll back.</p> <p>And no, if one <code>process_post_reply()</code> fails then the whole <code>process_post()</code> is not being rolled back - there's no magic there, only COMMIT and ROLLBACK on the database level, which means that what gets rolled back is only what has been written to the DB after the last commited <code>process_post_reply()</code>.</p> <p>Summarizing, <strong>I think that what you need</strong> is just a single <code>commit_on_success()</code> around <code>process_post</code>, possibly supported by <a href="http://docs.djangoproject.com/en/1.0/topics/db/transactions/#savepoints" rel="nofollow">transaction savepoints</a> - which unfortunately are available only in PostgreSQL backend, even though MySQL 5.x supports them as well.</p> <p><strong>EDIT 10 Apr 2012</strong>: Savepoint support for MySQL is now <a href="https://docs.djangoproject.com/en/1.4/topics/db/transactions/#savepoints" rel="nofollow">available in Django 1.4</a></p> <p><strong>EDIT 2 Jul 2014</strong>: Transaction management has been completely rewritten in Django 1.6 - <a href="https://docs.djangoproject.com/en/1.6/topics/db/transactions/" rel="nofollow">https://docs.djangoproject.com/en/1.6/topics/db/transactions/</a> and <code>commit_on_success</code> has been deprecated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload