示例#1
0
 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
0
 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
     # cache the entity now
     return self.cache_entity(entity)
示例#3
0
 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)
示例#4
0
 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
示例#5
0
 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