Author: phd
Date: 2009-05-18 10:43:37 -0600 (Mon, 18 May 2009)
New Revision: 3891
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/tests/test_basic.py
Log:
Fixed a bug that prevented to override per class _connection if there is sqlhub.processConnection.
Modified: SQLObject/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2009-05-18 16:42:32 UTC (rev 3890)
+++ SQLObject/trunk/docs/News.txt 2009-05-18 16:43:37 UTC (rev 3891)
@@ -173,6 +173,9 @@
* Use sqlmeta.idName instead of 'id' in all connection classes.
+* Fixed a bug that prevented to override per class _connection if there is
+ sqlhub.processConnection.
+
SQLObject 0.9.10
================
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2009-05-18 16:42:32 UTC (rev 3890)
+++ SQLObject/trunk/sqlobject/main.py 2009-05-18 16:43:37 UTC (rev 3891)
@@ -766,7 +766,10 @@
if hasattr(mod, '__connection__'):
connection = mod.__connection__
- if connection and not hasattr(cls, '_connection'):
+ # Do not check hasattr(cls, '_connection') here - it is possible
+ # SQLObject parent class has a connection attribute that came
+ # from sqlhub, e.g.; # check __dict__ only.
+ if connection and ('_connection' not in cls.__dict__):
cls.setConnection(connection)
# We have to check if there are columns in the inherited
Modified: SQLObject/trunk/sqlobject/tests/test_basic.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_basic.py 2009-05-18 16:42:32 UTC (rev 3890)
+++ SQLObject/trunk/sqlobject/tests/test_basic.py 2009-05-18 16:43:37 UTC (rev 3891)
@@ -311,3 +311,9 @@
setupClass(TestSO13)
test = TestSO13(name="test")
assert test.value == 1
+
+def test_connection_override():
+ sqlhub.processConnection = connectionForURI('sqlite:///db1')
+ class TestSO14(SQLObject):
+ _connection = connectionForURI('sqlite:///db2')
+ assert TestSO14._connection.uri() == 'sqlite:///db2'
|