#NEWLINE# @ db . listens_for ( db . Session , 'after_flush' ) #NEWLINE# def store_purge_keys( config , session , flush_context ) : #NEWLINE# #INDENT# cache_keys = config . registry [ 'cache_keys' ] #NEWLINE# purges = session . info . setdefault ( 'warehouse.cache.origin.purges' , set ( ) ) #NEWLINE# for obj in ( ( session . new | session . dirty ) | session . deleted ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# key_maker = cache_keys [ obj . __class__ ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# purges . update ( key_maker ( obj ) . purge )