permissions.py 文件源码

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

项目:baya 作者: counsyl 项目源码 文件源码
def decorate_method(self, fn, *args, **kwargs):
        """Decorate a view method.

        This is pretty simple - just attach a Gate as a `_gate` property
        to the function and then wrap it in the method dispatcher.
        """
        @functools.wraps(fn)
        def dispatcher(*args, **kwargs):
            largs = list(args)
            if isinstance(largs[0], BaseModelAdmin):
                func = functools.partial(fn, largs.pop(0))
            else:
                func = fn
            request = largs.pop(0)
            return (self.gate.allow_or_deny(request) or
                    func(request, *largs, **kwargs))
        dispatcher._gate = self.gate
        return dispatcher
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号