#NEWLINE# def managed( self , flag = True ) : #NEWLINE# #INDENT# '\n        Puts the transaction manager into a manual state: managed transactions have\n        to be committed explicitly by the user. If you switch off transaction\n        management and there is a pending commit/rollback, the data will be\n        commited.\n        ' #NEWLINE# top = self . transaction_state #NEWLINE# if top : #NEWLINE# #INDENT# top [ ( - 1 ) ] = flag #NEWLINE# if ( ( not top ) and self . is_dirty ( ) ) : #NEWLINE# #INDENT# self . _commit ( ) #NEWLINE# self . set_clean ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise TransactionManagementError ( "This code isn't under transaction management" )