diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-08-09 23:34:23 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-08-09 23:34:23 -0400 |
commit | f665ae746428cdb69e97d4576da29268a388569a (patch) | |
tree | a997fe24b9f0c7e7fa9df600b3e8f750b497d038 /lib/sqlalchemy/engine | |
parent | a9288ca5bd979d8aab9921f71bf5b722b1c3ab3d (diff) | |
download | sqlalchemy-f665ae746428cdb69e97d4576da29268a388569a.tar.gz |
this reorganizes things so the EventDescriptor and all is on a "Dispatch" object.
this leaves the original Event class alone so sphinx documents it.
this is all a mess right now but the pool/engine tests are working fully
at the moment so wanted to mark a working version.
Diffstat (limited to 'lib/sqlalchemy/engine')
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/threadlocal.py | 20 |
2 files changed, 13 insertions, 17 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 7b6ff5b7a..8d1138316 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1554,7 +1554,7 @@ class EngineEvents(event.Events): if issubclass(target.Connection, Connection): target.Connection = _proxy_connection_cls( Connection, - target.events) + target.dispatch) event.Events.listen(fn, identifier, target) def on_execute(self, conn, execute, clauseelement, *multiparams, **params): @@ -1627,7 +1627,7 @@ class Engine(Connectable, log.Identified): self.update_execution_options(**execution_options) - events = event.dispatcher(EngineEvents) + dispatch = event.dispatcher(EngineEvents) def update_execution_options(self, **opt): """update the execution_options dictionary of this :class:`Engine`. @@ -1851,11 +1851,7 @@ def _proxy_connection_cls(cls, dispatch): return orig def go(*arg, **kw): nested = _exec_recursive(conn, fns[1:], orig) - try: - ret = fns[0](conn, nested, *arg, **kw) - except IndexError: - import pdb - pdb.set_trace() + ret = fns[0](conn, nested, *arg, **kw) # TODO: need to get consistent way to check # for "they called the fn, they didn't", or otherwise # make some decision here how this is to work diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index 785c6e96a..b6e687b7c 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -27,7 +27,15 @@ class TLConnection(base.Connection): self.__opencount = 0 base.Connection.close(self) - +class TLEvents(base.EngineEvents): + @classmethod + def listen(cls, fn, identifier, target): + if issubclass(target.TLConnection, TLConnection): + target.TLConnection = base._proxy_connection_cls( + TLConnection, + target.dispatch) + base.EngineEvents.listen(fn, identifier, target) + class TLEngine(base.Engine): """An Engine that includes support for thread-local managed transactions.""" @@ -37,15 +45,7 @@ class TLEngine(base.Engine): super(TLEngine, self).__init__(*args, **kwargs) self._connections = util.threading.local() - class events(base.Engine.events): - @classmethod - def listen(cls, fn, identifier, target): - if issubclass(target.TLConnection, TLConnection): - target.TLConnection = base._proxy_connection_cls( - TLConnection, - target.events) - base.Engine.events.listen(fn, identifier, target) - events = event.dispatcher(events) + dispatch = event.dispatcher(TLEvents) def contextual_connect(self, **kw): if not hasattr(self._connections, 'conn'): |