예제 #1
0
 def get_value_in_values(entity):
     entity = get_entity(entity, store)
     try:
         return getattr(entity, attribute) in values
     except AttributeError:
         try:
             return entity.fields[attribute] in values
         except (AttributeError, KeyError):
             return False
예제 #2
0
 def _select(entity):
     """
     Return true if entity's attribute is < or > (depending on
     comparator) the value in the filter.
     """
     stored_entity = get_entity(entity, store)
     if hasattr(stored_entity, 'fields'):
         return comparator(func(getattr(stored_entity, attribute,
             stored_entity.fields.get(attribute, ''))), func(value))
     else:
         return comparator(func(getattr(stored_entity, attribute, None)),
                 func(value))
예제 #3
0
파일: sort.py 프로젝트: 24king/tiddlyweb
 def key_gen(entity):
     """
     Reify the attribute needed for sorting. If the entity
     has not already been loaded from the store, do so.
     """
     stored_entity = get_entity(entity, store)
     try:
         return func(getattr(stored_entity, attribute))
     except AttributeError as attribute_exc:
         try:
             return func(stored_entity.fields[attribute])
         except (AttributeError, KeyError) as exc:
             raise AttributeError('on %s, no attribute: %s, %s, %s'
                     % (stored_entity, attribute, attribute_exc, exc))
예제 #4
0
 def _select(entity):
     """
     Return true if entity's attribute is < or > (depending on
     comparator) the value in the filter.
     """
     stored_entity = get_entity(entity, store)
     if hasattr(stored_entity, 'fields'):
         return comparator(
             func(
                 getattr(stored_entity, attribute,
                         stored_entity.fields.get(attribute, ''))),
             func(value))
     else:
         return comparator(func(getattr(stored_entity, attribute, None)),
                           func(value))
예제 #5
0
파일: sort.py 프로젝트: sgml/tiddlyweb
 def key_gen(entity):
     """
     Reify the attribute needed for sorting. If the entity
     has not already been loaded from the store, do so.
     """
     stored_entity = get_entity(entity, store)
     try:
         return func(getattr(stored_entity, attribute))
     except AttributeError as attribute_exc:
         try:
             return func(stored_entity.fields[attribute])
         except (AttributeError, KeyError) as exc:
             raise AttributeError(
                 'on %s, no attribute: %s, %s, %s' %
                 (stored_entity, attribute, attribute_exc, exc))
예제 #6
0
 def _posfilter(entity):
     """
     Return True if the entity's attribute matches value.
     """
     stored_entity = get_entity(entity, store)
     return select(stored_entity, attribute, value)
예제 #7
0
 def _posfilter(entity):
     """
     Return True if the entity's attribute matches value.
     """
     stored_entity = get_entity(entity, store)
     return select(stored_entity, attribute, value)