#NEWLINE# def __exit__( self , exc_type , exc_value , traceback ) : #NEWLINE# #INDENT# connection = get_connection ( self . using ) #NEWLINE# if connection . savepoint_ids : #NEWLINE# #INDENT# sid = connection . savepoint_ids . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# connection . in_atomic_block = False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if connection . closed_in_transaction : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( exc_type is None ) and ( not connection . needs_rollback ) ) : #NEWLINE# #INDENT# if connection . in_atomic_block : #NEWLINE# #INDENT# if ( sid is not None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection . savepoint_commit ( sid ) #NEWLINE# #UNINDENT# except DatabaseError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection . savepoint_rollback ( sid ) #NEWLINE# #UNINDENT# except Error : #NEWLINE# #INDENT# connection . needs_rollback = True #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection . commit ( ) #NEWLINE# #UNINDENT# except DatabaseError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection . rollback ( ) #NEWLINE# #UNINDENT# except Error : #NEWLINE# #INDENT# connection . close ( ) #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# connection . needs_rollback = False #NEWLINE# if connection . in_atomic_block : #NEWLINE# #INDENT# if ( sid is None ) : #NEWLINE# #INDENT# connection . needs_rollback = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection . savepoint_rollback ( sid ) #NEWLINE# #UNINDENT# except Error : #NEWLINE# #INDENT# connection . needs_rollback = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection . rollback ( ) #NEWLINE# #UNINDENT# except Error : #NEWLINE# #INDENT# connection . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# if ( not connection . in_atomic_block ) : #NEWLINE# #INDENT# if connection . closed_in_transaction : #NEWLINE# #INDENT# connection . connection = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if connection . features . autocommits_when_autocommit_is_off : #NEWLINE# #INDENT# connection . autocommit = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# connection . set_autocommit ( True ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not connection . savepoint_ids ) and ( not connection . commit_on_exit ) ) : #NEWLINE# #INDENT# if connection . closed_in_transaction : #NEWLINE# #INDENT# connection . connection = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# connection . in_atomic_block = False