def _listen(cls, target, identifier, fn, propagate=True):
def listen(target_cls, *arg):
listen_cls = target()
if propagate and issubclass(target_cls, listen_cls):
return fn(target_cls, *arg)
elif not propagate and target_cls is listen_cls:
return fn(target_cls, *arg)
def remove(ref):
event.Events._remove(orm.instrumentation._instrumentation_factory,
identifier, listen)
target = weakref.ref(target.class_, remove)
event.Events._listen(orm.instrumentation._instrumentation_factory,
identifier, listen)
评论列表
文章目录