This patch is a cruded attemt to make @commit_on_success support nested transactions. See http://code.djangoproject.com/ticket/2227 for an explanation why this is usefull. --md@hudora.de Index: django/db/transaction.py =================================================================== --- django/db/transaction.py (revision 3262) +++ django/db/transaction.py (working copy) @@ -187,21 +187,26 @@ control in web apps. """ def _commit_on_success(*args, **kw): - try: - enter_transaction_management() - managed(True) + # only use transactions if we don't have already an ongoing transaction + thread_ident = thread.get_ident() + if thread_ident not in state or state[thread_ident] == []: try: - res = func(*args, **kw) - except Exception, e: - if is_dirty(): - rollback() - raise - else: - if is_dirty(): - commit() - return res - finally: - leave_transaction_management() + enter_transaction_management() + managed(True) + try: + res = func(*args, **kw) + except Exception, e: + if is_dirty(): + rollback() + raise + else: + if is_dirty(): + commit() + return res + finally: + leave_transaction_management() + else: + return func(*args, **kw) return _commit_on_success def commit_manually(func):