On 30 Mar, 07:24, Continuation <selforgani...@gmail.com> wrote: > If I have a view function that transfers money from savings to > checking account, is @transaction.commit_on_success the recommend way > to manage the transaction? > > So something like: > > @transaction.commit_on_success > def transfer(request): > ... > savings.withdraw(amount) > checking.deposit(amount) > > If I use @transaction.commit_on_success, do I still need > django.middleware.transaction.TransactionMiddleware? > > And all other database interactions will remain auto-commit, correct? >
If you take a look at TransactionMiddleware source: http://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/middleware/transaction.py then you'll see that it's just commit_on_success in disguise: http://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/db/transaction.py#L228 Also, you can take a look at my post here, to avoid some transaction- related problems in future: http://stackoverflow.com/questions/2235318/how-do-i-deal-with-this-race-condition-in-django/2235624#2235624 -- Tomasz Zielinski http://pyconsultant.eu -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.