diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-28 19:02:09 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-28 19:02:09 +0000 |
| commit | abb24ed648f1d22805e46e2a504b2dfed342bab8 (patch) | |
| tree | 6765cdde410bbf0b8e8a2f677e6d6a7a7d801bf5 /lib/sqlalchemy/engine | |
| parent | e36ec1407dbeb242b216c4714e9c5a1fc995073a (diff) | |
| download | sqlalchemy-abb24ed648f1d22805e46e2a504b2dfed342bab8.tar.gz | |
extra tests...
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/threadlocal.py | 14 |
1 files changed, 12 insertions, 2 deletions
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.""" |
