Jason Baker wrote:
> On Mon, Apr 5, 2010 at 5:55 PM, Michael Bayer
> <mike...@zzzcomputing.com>wrote:
>
>> I'm unclear on what usage you'd like to see.
>
>
> What I'm trying to do would be roughly equivalent to this:
>
> def query_foo(self):
>     logger = logging.getLogger(__name__ + '.' + self.__class__.__name__)
>     query = self.session.query(Foo)
>     logger.debug(query)
>     logger.debug(query.compile().params)
>     return query.all()
>
> However, this is pretty unmanageable.  The above method could be reduced
> to
> one line of code if not for the logging boilerplate.  So what I'd like to
> do
> is somehow be able to do the above, but without the logger boilerplate.


if you are looking for the method that is actually "doing something" (note
we assume here that 'self' above is not necessarily "Foo" - if you wanted
"Foo", that would just be query._mapper_zero().class_), you need to look
in the current stack (i.e. sys._getframe()), or otherwise apply some
transparent instrumentation to all methods (sys.settrace()) that assigns
state information to a thread-local registry.    The kind of logging
you're doing is specific to debugging and is nothing I'd be running in
production.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to