#NEWLINE# def _restore_snapshot( self , dirty_only = False ) : #NEWLINE# #INDENT# assert self . _is_transaction_boundary #NEWLINE# for s in set ( self . _new ) . union ( self . session . _new ) : #NEWLINE# #INDENT# self . session . _expunge_state ( s ) #NEWLINE# if s . key : #NEWLINE# #INDENT# del s . key #NEWLINE# #UNINDENT# #UNINDENT# for ( s , ( oldkey , newkey ) ) in self . _key_switches . items ( ) : #NEWLINE# #INDENT# self . session . identity_map . discard ( s ) #NEWLINE# s . key = oldkey #NEWLINE# self . session . identity_map . replace ( s ) #NEWLINE# #UNINDENT# for s in set ( self . _deleted ) . union ( self . session . _deleted ) : #NEWLINE# #INDENT# if s . deleted : #NEWLINE# #INDENT# del s . deleted #NEWLINE# #UNINDENT# self . session . _update_impl ( s , discard_existing = True ) #NEWLINE# #UNINDENT# assert ( not self . session . _deleted ) #NEWLINE# for s in self . session . identity_map . all_states ( ) : #NEWLINE# #INDENT# if ( ( not dirty_only ) or s . modified or ( s in self . _dirty ) ) : #NEWLINE# #INDENT# s . _expire ( s . dict , self . session . identity_map . _modified )