Hello!
On Wed, Mar 28, 2007 at 09:38:20PM +0200, Markus Gritsch wrote:
> the problem is, that
> doInTransaction() restores the old connection unconditionally to
> sqlhub.threadConnection, although self.getConnection() returns
> sqlhub.processConnection in case it is set. And since
> doInTransaction() sets sqlhub.threadConnection, changing
> sqlhub.processConnection afterwards has no effect anymore.
Any opinion on the attached patch?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
Index: dbconnection.py
===================================================================
--- dbconnection.py (revision 2478)
+++ dbconnection.py (working copy)
@@ -973,9 +973,17 @@
"""
# @@: In Python 2.5, something usable with with: should also
# be added.
- old_conn = self.getConnection()
+ try:
+ old_conn = self.threadingLocal.connection
+ old_conn_is_threading = True
+ except AttributeError:
+ old_conn = self.processConnection
+ old_conn_is_threading = False
conn = old_conn.transaction()
- self.threadConnection = conn
+ if old_conn_is_threading:
+ self.threadConnection = conn
+ else:
+ self.processConnection = conn
try:
try:
value = func(*args, **kw)
@@ -986,7 +994,10 @@
conn.commit(close=True)
return value
finally:
- self.threadConnection = old_conn
+ if old_conn_is_threading:
+ self.threadConnection = old_conn
+ else:
+ self.processConnection = old_conn
def _set_threadConnection(self, value):
self.threadingLocal.connection = value
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss