collection.py 文件源码

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

项目:lemongraph 作者: NationalSecurityAgency 项目源码 文件源码
def graph(self, uuid=None, hook=True, ctx=None, user=None, roles=None, **kwargs):
        if uuid is None and kwargs.get('create', False):
            uuid = uuidgen()
        for k,v in self.graph_opts.iteritems():
            if k not in kwargs:
                kwargs[k] = v
        if hook:
            kwargs['hooks'] = CollectionHooks(uuid, self)
        try:
            g = Graph(self.graph_path(uuid), **kwargs)
        except:
            self.remove(uuid) if ctx is None else ctx.remove(uuid)
            raise
        if user is not None:
            # new graph - do not check creds
            if g.updated:
                pass
            else:
                if not self.user_allowed(g, user, roles):
                    g.close()
                    raise OSError(errno.EPERM, 'Permission denied', uuid)
        return g
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号