Author: phd
Date: 2007-04-09 09:25:03 -0600 (Mon, 09 Apr 2007)
New Revision: 2500
Modified:
home/phd/SQLObject/paramstyles/sqlobject/conftest.py
home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_deep_inheritance.py
Log:
Merged patches from the revisions 2483:2499 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/conftest.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/conftest.py 2007-04-09 15:19:59 UTC (rev 2499)
+++ home/phd/SQLObject/paramstyles/sqlobject/conftest.py 2007-04-09 15:25:03 UTC (rev 2500)
@@ -30,8 +30,8 @@
'mssql': 'mssql://sa:@127.0.0.1/test'
}
-Option = py.test.Config.Option
-option = py.test.Config.addoptions(
+Option = py.test.config.Option
+option = py.test.config.addoptions(
"SQLObject options",
Option('-D', '--Database',
action="store", dest="Database", default='sqlite',
Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2007-04-09 15:19:59 UTC (rev 2499)
+++ home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2007-04-09 15:25:03 UTC (rev 2500)
@@ -1022,9 +1022,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)
@@ -1035,7 +1043,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
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_deep_inheritance.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_deep_inheritance.py 2007-04-09 15:19:59 UTC (rev 2499)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_deep_inheritance.py 2007-04-09 15:25:03 UTC (rev 2500)
@@ -23,12 +23,10 @@
Try to creae an Manager without specifying a position.
this should fail without leaving any partial records in
the database.
+
"""
+ setupClass([DIManager, DIEmployee, DIPerson])
- setupClass(DIManager)
- setupClass(DIEmployee)
- setupClass(DIPerson)
-
kwargs ={'firstName':'John', 'lastname':'Doe'}
raises(TypeError, DIManager, **kwargs)
#what we really need to check for is partial records in the database.
@@ -37,13 +35,8 @@
assert persons.count() == 0
def test_deep_inheritance():
+ setupClass([DIManager, DIEmployee, DIPerson])
- cache = getConnection().cache
-
- setupClass(DIManager)
- setupClass(DIEmployee)
- setupClass(DIPerson)
-
manager = DIManager(firstName='Project', lastName='Manager',
position='Project Manager')
manager_id = manager.id
@@ -51,6 +44,8 @@
position='Project leader', manager=manager).id
person_id = DIPerson(firstName='Oneof', lastName='Authors',
manager=manager).id
+
+ cache = getConnection().cache
cache.clear()
managers = list(DIManager.select())
|