#NEWLINE# def __enter__( self ) : #NEWLINE# #INDENT# connection = get_connection ( self . using ) #NEWLINE# if ( not connection . in_atomic_block ) : #NEWLINE# #INDENT# connection . commit_on_exit = True #NEWLINE# connection . needs_rollback = False #NEWLINE# if ( not connection . get_autocommit ( ) ) : #NEWLINE# #INDENT# if connection . features . autocommits_when_autocommit_is_off : #NEWLINE# #INDENT# raise TransactionManagementError ( "Your database backend doesn't behave properly when autocommit is off. Turn it on before using 'atomic'." ) #NEWLINE# #UNINDENT# if ( not self . savepoint ) : #NEWLINE# #INDENT# raise TransactionManagementError ( "The outermost 'atomic' block cannot use savepoint = False when autocommit is off." ) #NEWLINE# #UNINDENT# connection . in_atomic_block = True #NEWLINE# connection . commit_on_exit = False #NEWLINE# #UNINDENT# #UNINDENT# if connection . in_atomic_block : #NEWLINE# #INDENT# if ( self . savepoint and ( not connection . needs_rollback ) ) : #NEWLINE# #INDENT# sid = connection . savepoint ( ) #NEWLINE# connection . savepoint_ids . append ( sid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# connection . savepoint_ids . append ( None ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if connection . features . autocommits_when_autocommit_is_off : #NEWLINE# #INDENT# connection . _start_transaction_under_autocommit ( ) #NEWLINE# connection . autocommit = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# connection . set_autocommit ( False ) #NEWLINE# #UNINDENT# connection . in_atomic_block = True