Just what I needed, thanks very much! Here's where my code ended up (it
works!):
class CacheQuery(BaseQuery):
def __init__(self, *args, **kwargs):
super(CacheQuery, self).__init__(*args, **kwargs)
self.ids = []
def __iter__(self):
if self.ids:
return iter([get_from_cache(self.session,
self._primary_entity.type, id) for id in self.ids])
else:
return super(CacheQuery, self).__iter__()
def filter_by(self, **kwargs):
id_query =
self.session.query(self._primary_entity.type.id).filter_by(**kwargs)
self.ids = [item[0] for item in id_query.all()] # flatten result
return self
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.