#NEWLINE# def delete( self , instance_or_query ) : #NEWLINE# #INDENT# 'Delete an ``instance`` or a ``query``.\n\n        Adds ``instance_or_query`` to this :class:`Session` list\n        of data to be deleted. If the session is not in a\n        :ref:`transactional state <transactional-state>`, this operation\n        commits changes to the backend server immediately.\n\n        :parameter instance_or_query: a :class:`Model` instance or\n            a :class:`Query`.\n        ' #NEWLINE# sm = self . model ( instance_or_query ) #NEWLINE# if is_query ( instance_or_query ) : #NEWLINE# #INDENT# if ( instance_or_query . session is not instance_or_query ) : #NEWLINE# #INDENT# raise ValueError ( 'Adding a query generated by another session' ) #NEWLINE# #UNINDENT# sm . _delete_query . append ( instance_or_query ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# instance_or_query = sm . delete ( instance_or_query , self ) #NEWLINE# #UNINDENT# if ( not self . transaction ) : #NEWLINE# #INDENT# transaction = self . begin ( ) #NEWLINE# return transaction . commit ( ( lambda : transaction . deleted . get ( sm . _meta ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return instance_or_query