Esempio n. 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
Esempio n. 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))
Esempio n. 3
0
 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))
Esempio n. 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))
Esempio n. 5
0
 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))
Esempio n. 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)
Esempio n. 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)