On Fri, May 31, 2013 at 4:03 PM, Claudio Freire <klaussfre...@gmail.com>wrote:
> With: > > class CacheableQuery(sqlalchemy.orm.query.Query): > > def __init__(self, *p, **kw): > > self._cached_context = None > > self._cached_context_labels = None > > super(CacheableQuery, self).__init__(*p, **kw) > > @sqlalchemy.orm.query._generative() > > def bake(self, labels=True): > > self._compile_context(labels) > > > def _compile_context(self, labels=True): > > if self._cached_context and self._cached_context_labels == labels: > > context = super(CacheableQuery, self)._compile_context(labels) > > cached = self._cached_context > context.statement = cached.statement > else: > > context = super(CacheableQuery, self)._compile_context(labels) > > self._cached_context_labels = labels > > self._cached_context = context > > return context > Damn gmail With: . class CacheableQuery(sqlalchemy.orm.query.Query): . def __init__(self, *p, **kw): . self._cached_context = None . self._cached_context_labels = None . super(CacheableQuery, self).__init__(*p, **kw) . @sqlalchemy.orm.query._generative() . def bake(self, labels=True): . self._compile_context(labels) . . def _compile_context(self, labels=True): . if self._cached_context and self._cached_context_labels == labels: . context = super(CacheableQuery, self)._compile_context(labels) . cached = self._cached_context . context.statement = cached.statement . else: . context = super(CacheableQuery, self)._compile_context(labels) . self._cached_context_labels = labels . self._cached_context = context . . return context -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.