events.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pyetje 作者: rorlika 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号