Logo Search packages:      
Sourcecode: zeitgeist version File versions

def _zeitgeist::engine::base::Entity::lookup (   klass,
  value = None,
  id = None 
)

Look up an entity by value or id, return None if the
   entity is not known

Definition at line 91 of file base.py.

00091                                             :
            """Look up an entity by value or id, return None if the
               entity is not known"""
            if value:
                  value = unicode(value)
                  if klass.CACHE is not None and value in klass.CACHE:
                        return klass.CACHE[value]
                  ent = _store.find(klass, klass.value == value).one()
                  if klass.CACHE is not None and ent:
                        klass.CACHE[value] = ent
                  return ent
            elif id:
                  return _store.get(id) # Lookup on primary key
            else:
                  raise ValueError("Looking up Entity without a value or id")
      
      @classmethod
      def lookup_or_create(klass, value):


Generated by  Doxygen 1.6.0   Back to index