Thinking about it more, I should probably just override the methods of
Connection itself and not worry about subclasses.  If someone is
overriding _execute*, he can do his own damn profiling. :)

On 1/17/07, Jonathan Ellis <[EMAIL PROTECTED]> wrote:
I finally came back to this.  Here's what I ended up with:

# I tried to enable profiling on a per-engine level before resorting to this
# hack. (Monkey-patching classes by scanning the gc! Woot!)
#
# Per-engine profile turns out to totally not work because there's so many
# layers of "clever" stuff going on (well, primarily PoolConnectionProvider
# returning proxies instead of real Connections) that it's really impossible to
# decorate Connections in a general manner by relying on
engine.connection_provider.
# Too bad, because it was rather more elegant.
#
# This will work no matter how many layers of proxies there are...
def enable_profiling():
    import gc
    for o in gc.get_objects():
        if isinstance(o, type):
            if o == Connection or Connection in o.__bases__:
                o._execute = _profilingexecute
                o._executemany = _profilingexecutemany

where the _profilingexecute methods do pretty much what was discussed before.

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

Reply via email to