#NEWLINE# def delete( self , instance ) : #NEWLINE# #INDENT# 'Mark an instance as deleted.\n\n        The database delete operation occurs upon ``flush()``.\n\n        ' #NEWLINE# if self . _warn_on_events : #NEWLINE# #INDENT# self . _flush_warning ( 'Session.delete()' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# state = attributes . instance_state ( instance ) #NEWLINE# #UNINDENT# except exc . NO_STATE : #NEWLINE# #INDENT# raise exc . UnmappedInstanceError ( instance ) #NEWLINE# #UNINDENT# if ( state . key is None ) : #NEWLINE# #INDENT# raise sa_exc . InvalidRequestError ( ( "Instance '%s' is not persisted" % state_str ( state ) ) ) #NEWLINE# #UNINDENT# if ( state in self . _deleted ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# self . _attach ( state , include_before = True ) #NEWLINE# cascade_states = list ( state . manager . mapper . cascade_iterator ( 'delete' , state ) ) #NEWLINE# self . _deleted [ dct_ ] = state . obj ( ) #NEWLINE# self . identity_map . add ( state ) #NEWLINE# for ( o , m , st_ , dct_ ) in cascade_states : #NEWLINE# #INDENT# self . _delete_impl ( st_ )