def _locate_roles_and_methods(cls):
 roles = {}
 methods = {}
 for supercls in cls.__mro__:
  for (name, method) in vars(supercls).items():
   if (not util.callable(method)):
    continue
   if hasattr(method, '_sa_instrument_role'):
    role = method._sa_instrument_role
    assert (role in ('appender', 'remover', 'iterator', 'linker', 'converter'))
    roles.setdefault(role, name)
   (before, after) = (None, None)
   if hasattr(method, '_sa_instrument_before'):
    (op, argument) = method._sa_instrument_before
    assert (op in ('fire_append_event', 'fire_remove_event'))
    before = (op, argument)
   if hasattr(method, '_sa_instrument_after'):
    op = method._sa_instrument_after
    assert (op in ('fire_append_event', 'fire_remove_event'))
    after = op
   if before:
    methods[name] = (before + (after,))
   elif after:
    methods[name] = (None, None, after)
 return (roles, methods)

def _locate_roles_and_methods ( cls ) : roles = { } methods = { } for supercls in cls . __mro__ : for ( name , method ) in vars ( supercls ) . items ( ) : if ( not util . callable ( method ) ) : continue if hasattr ( method , '_sa_instrument_role' ) : role = method . _sa_instrument_role assert ( role in ( 'appender' , 'remover' , 'iterator' , 'linker' , 'converter' ) ) roles . setdefault ( role , name ) ( before , after ) = ( None , None ) if hasattr ( method , '_sa_instrument_before' ) : ( op , argument ) = method . _sa_instrument_before assert ( op in ( 'fire_append_event' , 'fire_remove_event' ) ) before = ( op , argument ) if hasattr ( method , '_sa_instrument_after' ) : op = method . _sa_instrument_after assert ( op in ( 'fire_append_event' , 'fire_remove_event' ) ) after = op if before : methods [ name ] = ( before + ( after , ) ) elif after : methods [ name ] = ( None , None , after ) return ( roles , methods )
search for _sa_instrument_role-decorated methods in method resolution order .