def get_connection(self, bind=None):
"""Return a py2neo.Graph object based on config settings"""
# assume default if no bind specified
if bind is None:
bind = self.DEFAULT_GRAPH_KEY
# credentials are bound to the application context
ctx = stack.top
if ctx is not None:
if not hasattr(ctx, 'ogm_graphs'.format(bind)):
ctx.ogm_graphs = {}
if bind not in ctx.ogm_graphs:
ctx.ogm_graphs[bind] = self.connect(bind=bind)
return ctx.ogm_graphs[bind]
raise OutOfApplicationContextError()
评论列表
文章目录