From abb24ed648f1d22805e46e2a504b2dfed342bab8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 28 May 2006 19:02:09 +0000 Subject: extra tests... --- lib/sqlalchemy/engine/threadlocal.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/engine') diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index d909cbeda..84e5a7dc4 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -14,7 +14,12 @@ class TLSession(object): try: return self.__transaction except AttributeError: - return base.Connection(self.engine, close_with_result=close_with_result) + return TLConnection(self, close_with_result=close_with_result) + def set_transaction(self, tlconnection, trans): + if self.__tcount == 0: + self.__transaction = tlconnection + self.__trans = trans + self.__tcount += 1 def begin(self): if self.__tcount == 0: self.__transaction = self.get_connection() @@ -41,7 +46,12 @@ class TLSession(object): def is_begun(self): return self.__tcount > 0 - +class TLConnection(base.Connection): + def __init__(self, session, close_with_result): + base.Connection.__init__(self, session.engine, close_with_result=close_with_result) + self.__session = session + # TODO: get begin() to communicate with the Session to maintain the same transactional state + class TLEngine(base.ComposedSQLEngine): """a ComposedSQLEngine that includes support for thread-local managed transactions. This engine is better suited to be used with threadlocal Pool object.""" -- cgit v1.2.1