From f665ae746428cdb69e97d4576da29268a388569a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 9 Aug 2010 23:34:23 -0400 Subject: 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. --- lib/sqlalchemy/engine/threadlocal.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy/engine/threadlocal.py') 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'): -- cgit v1.2.1