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
评论列表
文章目录