On Fri, Jun 7, 2013 at 1:56 PM, Claudio Freire <klaussfre...@gmail.com> wrote: > > This is my current BakedQuery: > > class BakedQuery(sqlalchemy.orm.query.Query):
F**k gmail again. Why the F+!k doesn't it show me that it'll bork all whitespace before I hit send... I smell a bug report coming... class BakedQuery(sqlalchemy.orm.query.Query): . _baked_context = None . _baked_cache = None . . def _clone(self): . rv = super(BakedQuery, self)._clone() . try: . del rv._baked_context . del rv._baked_cache . except AttributeError: . pass . return rv . . def params(self, *p, **kw): . rv = super(BakedQuery, self).params(*p, **kw) . rv._baked_context = self._baked_context . rv._baked_cache = self._baked_cache . return rv . . def with_session(self, *p, **kw): . rv = super(BakedQuery, self).with_session(*p, **kw) . rv._baked_context = self._baked_context . rv._baked_cache = self._baked_cache . return rv . . @sqlalchemy.orm.query._generative() . def bake_as(self, name, cache): . """Freeze the statement used by this Query.""" . . if name not in cache: . cache[name] = context = self._compile_context() . del context.session . del context.query . self._baked_context = cache[name] . self._baked_cache = cache . . def _compile_context(self, **kw): . if self._baked_context is not None: . QueryContext = sqlalchemy.orm.query.QueryContext . context = QueryContext.__new__(QueryContext) . context.__dict__.update(self._baked_context.__dict__) . context.query = self . context.session = self.session . # need to fix these names, urg . context.attributes = context._attributes = context.attributes.copy() . return context . else: . return super(BakedQuery, self)._compile_context(**kw) . . def _execute_and_instances(self, querycontext): . if self._baked_cache is not None: . self = self.execution_options(compiled_cache=self._baked_cache) . return super(BakedQuery, self)._execute_and_instances(querycontext) -- 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.