Author: phd
Date: 2010-02-26 14:22:50 -0700 (Fri, 26 Feb 2010)
New Revision: 4107
Modified:
SQLObject/branches/0.11/docs/News.txt
SQLObject/branches/0.11/sqlobject/main.py
SQLObject/branches/0.11/sqlobject/tests/test_select.py
Log:
Do not set _perConnection flag if get() or _init() is passed the same
connection; this is often the case with select().
Modified: SQLObject/branches/0.11/docs/News.txt
===================================================================
--- SQLObject/branches/0.11/docs/News.txt 2010-02-10 15:49:07 UTC (rev 4106)
+++ SQLObject/branches/0.11/docs/News.txt 2010-02-26 21:22:50 UTC (rev 4107)
@@ -14,6 +14,9 @@
connection is not a transaction and is in autocommit mode - remove
parent row(s).
+* Do not set _perConnection flag if get() or _init() is passed the same
+ connection; this is often the case with select().
+
SQLObject 0.11.3
================
Modified: SQLObject/branches/0.11/sqlobject/main.py
===================================================================
--- SQLObject/branches/0.11/sqlobject/main.py 2010-02-10 15:49:07 UTC (rev 4106)
+++ SQLObject/branches/0.11/sqlobject/main.py 2010-02-26 21:22:50 UTC (rev 4107)
@@ -922,7 +922,7 @@
# If no connection was given, we'll inherit the class
# instance variable which should have a _connection
# attribute.
- if connection is not None:
+ if (connection is not None) and (self._connection != connection):
self._connection = connection
# Sometimes we need to know if this instance is
# global or tied to a particular connection.
@@ -1208,9 +1208,10 @@
# Pass the connection object along if we were given one.
if kw.has_key('connection'):
- self._connection = kw['connection']
- self.sqlmeta._perConnection = True
- del kw['connection']
+ connection = kw.pop('connection')
+ if self._connection != connection:
+ self._connection = connection
+ self.sqlmeta._perConnection = True
self._SO_writeLock = threading.Lock()
Modified: SQLObject/branches/0.11/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.11/sqlobject/tests/test_select.py 2010-02-10 15:49:07 UTC (rev 4106)
+++ SQLObject/branches/0.11/sqlobject/tests/test_select.py 2010-02-26 21:22:50 UTC (rev 4107)
@@ -180,3 +180,8 @@
setupClass(IterTest)
IterTest(name='sqlobject')
IterTest.select(IterTest.q.name==u'sqlobject')
+
+def test_select_perConnection():
+ setupClass(IterTest)
+ IterTest(name='a')
+ assert not IterTest.select().getOne().sqlmeta._perConnection
|