本文整理汇总了Python中opencontext_py.apps.entities.entity.models.Entity.context_dereference方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.context_dereference方法的具体用法?Python Entity.context_dereference怎么用?Python Entity.context_dereference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opencontext_py.apps.entities.entity.models.Entity
的用法示例。
在下文中一共展示了Entity.context_dereference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_entity_db
# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import context_dereference [as 别名]
def get_entity_db(self, identifier, context_id, is_path=False):
""" returns an entity object
via database calls
"""
output = False
found = False
entity = Entity()
if is_path:
found = entity.context_dereference(identifier)
else:
found = entity.dereference(identifier)
if found is False:
# case of linked data slugs
found = entity.dereference(identifier, identifier)
if found:
if is_path:
self.entities[context_id] = entity
else:
self.entities[identifier] = entity
if entity.uuid is not False:
self.entities[entity.uuid] = entity
if entity.slug is not False:
self.entities[entity.slug] = entity
output = entity
return output
示例2: _get_cache_context_entity_db
# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import context_dereference [as 别名]
def _get_cache_context_entity_db(self, context):
""" dereference an item by spatial context path """
found = False
entity = Entity()
entity.get_context = True
found = entity.context_dereference(context)
# print('look for ' + context)
if not found:
# maybe we're passing a uuid, uri or slug?
found = entity.dereference(context)
if not found:
# case of linked data slugs
found = entity.dereference(context, context)
if not found:
# give up, we can't find it.
return False
else:
# cache the entity now
return self.cache_entity(entity)
示例3: get_entity
# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import context_dereference [as 别名]
def get_entity(self, identifier, is_path=False):
""" looks up an entity """
output = False
identifier = http.urlunquote_plus(identifier)
if identifier in self.entities:
# best case scenario, the entity is already looked up
output = self.entities[identifier]
else:
found = False
entity = Entity()
if is_path:
found = entity.context_dereference(identifier)
else:
found = entity.dereference(identifier)
if found is False:
# case of linked data slugs
found = entity.dereference(identifier, identifier)
if found:
output = entity
return output