Ticket #17624: django-bug-17624.patch

File django-bug-17624.patch, 1.5 KB (added by George Lund, 13 years ago)

patch to make Transaction recognise failure in more cases

  • django/db/transaction.py

     
    204204        self.entering(self.using)
    205205
    206206    def __exit__(self, exc_type, exc_value, traceback):
    207         self.exiting(exc_value, self.using)
     207        success = exc_type is None and exc_value is None and traceback is None
     208        self.exiting(success, self.using)
    208209
    209210    def __call__(self, func):
    210211        @wraps(func)
     
    254255        enter_transaction_management(managed=False, using=using)
    255256        managed(False, using=using)
    256257
    257     def exiting(exc_value, using):
     258    def exiting(success, using):
    258259        leave_transaction_management(using=using)
    259260
    260261    return _transaction_func(entering, exiting, using)
     
    270271        enter_transaction_management(using=using)
    271272        managed(True, using=using)
    272273
    273     def exiting(exc_value, using):
     274    def exiting(success, using):
    274275        try:
    275             if exc_value is not None:
     276            if not success:
    276277                if is_dirty(using=using):
    277278                    rollback(using=using)
    278279            else:
     
    298299        enter_transaction_management(using=using)
    299300        managed(True, using=using)
    300301
    301     def exiting(exc_value, using):
     302    def exiting(success, using):
    302303        leave_transaction_management(using=using)
    303304
    304305    return _transaction_func(entering, exiting, using)
Back to Top