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
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))
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))
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))
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))
def _posfilter(entity): """ Return True if the entity's attribute matches value. """ stored_entity = get_entity(entity, store) return select(stored_entity, attribute, value)