diff options
Diffstat (limited to 'lib/sqlalchemy/engine/threadlocal.py')
-rw-r--r-- | lib/sqlalchemy/engine/threadlocal.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index e4b2859dc..91b16ed5f 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -17,7 +17,7 @@ class TLSession(object): try: return self.__transaction._increment_connect() except AttributeError: - return TLConnection(self, self.engine.pool.connect(), close_with_result=close_with_result) + return self.engine.TLConnection(self, self.engine.pool.connect(), close_with_result=close_with_result) def reset(self): try: @@ -81,11 +81,14 @@ class TLSession(object): class TLConnection(base.Connection): - def __init__(self, session, connection, close_with_result): - base.Connection.__init__(self, session.engine, connection, close_with_result=close_with_result) + def __init__(self, session, connection, **kwargs): + base.Connection.__init__(self, session.engine, connection, **kwargs) self.__session = session self.__opencount = 1 + def _branch(self): + return self.engine.Connection(self.engine, self.connection, _branch=True) + def session(self): return self.__session session = property(session) @@ -168,6 +171,12 @@ class TLEngine(base.Engine): super(TLEngine, self).__init__(*args, **kwargs) self.context = util.ThreadLocal() + proxy = kwargs.get('proxy') + if proxy: + self.TLConnection = base._proxy_connection_cls(TLConnection, proxy) + else: + self.TLConnection = TLConnection + def session(self): "Returns the current thread's TLSession" if not hasattr(self.context, 'session'): |