def _listen(cls, target, identifier, fn, active_history=False,
raw=False, retval=False,
propagate=False):
if active_history:
target.dispatch._active_history = True
# TODO: for removal, need to package the identity
# of the wrapper with the original function.
if not raw or not retval:
orig_fn = fn
def wrap(target, value, *arg):
if not raw:
target = target.obj()
if not retval:
orig_fn(target, value, *arg)
return value
else:
return orig_fn(target, value, *arg)
fn = wrap
event.Events._listen(target, identifier, fn, propagate)
if propagate:
manager = orm.instrumentation.manager_of_class(target.class_)
for mgr in manager.subclass_managers(True):
event.Events._listen(mgr[target.key], identifier, fn, True)
评论列表
文章目录