当前位置: 首页>>代码示例>>Python>>正文


Python Entity.get_context方法代码示例

本文整理汇总了Python中opencontext_py.apps.entities.entity.models.Entity.get_context方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.get_context方法的具体用法?Python Entity.get_context怎么用?Python Entity.get_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opencontext_py.apps.entities.entity.models.Entity的用法示例。


在下文中一共展示了Entity.get_context方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_cache_entity_db

# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import get_context [as 别名]
 def _get_cache_entity_db(self, identifier):
     """Get an entity object from the database, if successful, cache it."""
     found = False
     entity = Entity()
     entity.get_context = True
     entity.get_thumbnail = True
     found = entity.dereference(identifier)
     if not found:
         # case of linked data slugs
         found = entity.dereference(identifier, identifier)
     if not found:
         return False
     else:
         # cache the entity now
         return self.cache_entity(entity)
开发者ID:ekansa,项目名称:open-context-py,代码行数:17,代码来源:memorycache.py

示例2: get_field_parent_entity

# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import get_context [as 别名]
 def get_field_parent_entity(self, field_num):
     """ Get's a parent entity named for a given field """
     parent_entity_found = False
     self.field_parent_entities[field_num] = False
     parent_anno = ImportFieldAnnotation.objects\
                                        .filter(source_id=self.source_id,
                                                field_num=field_num,
                                                predicate=ImportFieldAnnotation.PRED_CONTAINED_IN)[:1]
     if len(parent_anno) > 0:
         ent = Entity()
         ent.get_context = True
         found = ent.dereference(parent_anno[0].object_uuid)
         if found:
             self.field_parent_entities[field_num] = ent
             parent_entity_found = True
     return parent_entity_found
开发者ID:portableant,项目名称:open-context-py,代码行数:18,代码来源:subjects.py

示例3: _get_cache_context_entity_db

# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import get_context [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)
开发者ID:ekansa,项目名称:open-context-py,代码行数:21,代码来源:memorycache.py

示例4: get_context_entity_db

# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import get_context [as 别名]
 def get_context_entity_db(self, identifier):
     """ returns an entity object
         via database calls
     """
     output = False
     entity = Entity()
     entity.get_context = True
     found = entity.dereference(identifier)
     if found is False:
         # case of linked data slugs
         found = entity.dereference(identifier, identifier)
     if found:
         self.context_entities[identifier] = entity
         if entity.uuid is not False:
             self.context_entities[entity.uuid] = entity
         if entity.slug is not False:
             self.context_entities[entity.slug] = entity
         output = entity
     return output
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:21,代码来源:memorycache.py

示例5: add_to_request

# 需要导入模块: from opencontext_py.apps.entities.entity.models import Entity [as 别名]
# 或者: from opencontext_py.apps.entities.entity.models.Entity import get_context [as 别名]
 def add_to_request(self,
                    param,
                    new_value,
                    add_to_value=None):
     """ adds to the new request object a parameter and value """
     if self.base_request_json is not False:
         # start of with JSON encoded base request parameters
         new_rparams = json.loads(self.base_request_json)
     elif self.base_r_full_path is not False:
         # start of with parsing a URL string
         new_rparams = self.make_base_params_from_url(self.base_r_full_path)
     elif self.base_request is not False:
         # start with a dictionary object of the base request
         # for some reason this often leads to memory errors
         new_rparams = self.base_request
     else:
         new_rparams = {}
     if 'start' in new_rparams and self.remove_start_param:
         # remove paging information when composing a new link
         new_rparams.pop('start', None)
     if param == 'path':
         entity = Entity()
         entity.get_context = True
         found = entity.dereference(new_value)
         if found:
             # convert the (slug) value into a context path
             new_value = entity.context
     if param not in new_rparams:
         if param == 'path':
             new_rparams[param] = new_value
         else:
             new_rparams[param] = [new_value]
     else:
         if param == 'path':
             new_rparams['path'] = new_value
         else:
             if add_to_value is not None:
                 new_list = []
                 old_found = False
                 for old_val in new_rparams[param]:
                     old_prefix = self.remove_solr_part(old_val)
                     first_last_old_val = False
                     if self.hierarchy_delim in old_val:
                         old_val_ex = old_val.split(self.hierarchy_delim)
                         if len(old_val_ex) > 2:
                             first_last_old_val = old_val_ex[0]
                             first_last_old_val += self.hierarchy_delim
                             first_last_old_val += old_val_ex[-1]
                     if old_val == add_to_value:
                         old_found = True
                         new_list_val = old_val + self.hierarchy_delim + new_value
                     elif old_prefix == add_to_value:
                         old_found = True
                         new_list_val = old_prefix + self.hierarchy_delim + new_value
                     elif first_last_old_val == add_to_value:
                         old_found = True
                         new_list_val = old_prefix + self.hierarchy_delim + new_value
                     else:
                         new_list_val = old_val
                     new_list.append(new_list_val)
                 if old_found is False:
                     if self.partial_param_val_match:
                         for old_val in new_rparams[param]:
                             if add_to_value in old_val:
                                 old_found = True
                                 old_prefix = self.remove_solr_part(old_val)
                                 new_list_val = old_prefix + self.hierarchy_delim + new_value
                                 # add the new item
                                 new_list.append(new_list_val)
                                 # remove the old
                                 new_list.remove(old_val)
                 new_rparams[param] = new_list
                 if old_found is False:
                     new_rparams[param].append(new_value)
             else:
                 new_rparams[param].append(new_value)
     return new_rparams
开发者ID:portableant,项目名称:open-context-py,代码行数:79,代码来源:filterlinks.py


注:本文中的opencontext_py.apps.entities.entity.models.Entity.get_context方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。