#NEWLINE# def save_obj( base_mapper , states , uowtransaction , single = False ) : #NEWLINE# #INDENT# 'Issue ``INSERT`` and/or ``UPDATE`` statements for a list\n    of objects.\n\n    This is called within the context of a UOWTransaction during a\n    flush operation, given a list of states to be flushed.  The\n    base mapper in an inheritance hierarchy handles the inserts/\n    updates for all descendant mappers.\n\n    ' #NEWLINE# if ( ( not single ) and ( not base_mapper . batch ) ) : #NEWLINE# #INDENT# for state in _sort_states ( states_to_update ) : #NEWLINE# #INDENT# save_obj ( base_mapper , [ state ] , uowtransaction , single = True ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# ( states_to_insert , states_to_update ) = _organize_states_for_save ( base_mapper , states , uowtransaction ) #NEWLINE# cached_connections = _cached_connection_dict ( base_mapper ) #NEWLINE# for ( table , mapper ) in base_mapper . _sorted_tables . items ( ) : #NEWLINE# #INDENT# insert = _collect_insert_commands ( base_mapper , uowtransaction , table , states_to_insert ) #NEWLINE# update = _collect_update_commands ( base_mapper , uowtransaction , table , states_to_update ) #NEWLINE# if update : #NEWLINE# #INDENT# _emit_update_statements ( base_mapper , uowtransaction , cached_connections , mapper , table , update ) #NEWLINE# #UNINDENT# if insert : #NEWLINE# #INDENT# _emit_insert_statements ( base_mapper , uowtransaction , cached_connections , mapper , table , insert ) #NEWLINE# #UNINDENT# #UNINDENT# _finalize_insert_update_commands ( base_mapper , uowtransaction , states_to_insert , states_to_update )