In Django 1.4, the DatabaseOperations constructor takes
a mandatory connection argument, so let's handle the
TypeError, and make the application compatible with both
Django 1.3 and 1.4.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 frontend/db/backends/afe/base.py        |    5 ++++-
 frontend/db/backends/afe_sqlite/base.py |    5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/frontend/db/backends/afe/base.py b/frontend/db/backends/afe/base.py
index 067abac..8c15e8c 100644
--- a/frontend/db/backends/afe/base.py
+++ b/frontend/db/backends/afe/base.py
@@ -18,5 +18,8 @@ class DatabaseWrapper(MySQLDatabaseWrapper):
     def __init__(self, *args, **kwargs):
         super(DatabaseWrapper, self).__init__(*args, **kwargs)
         self.creation = MySQLCreation(self)
-        self.ops = DatabaseOperations()
+        try:
+            self.ops = DatabaseOperations()
+        except TypeError:
+            self.ops = DatabaseOperations(connection=kwargs.get('connection'))
         self.introspection = MySQLIntrospection(self)
diff --git a/frontend/db/backends/afe_sqlite/base.py 
b/frontend/db/backends/afe_sqlite/base.py
index 81f28d7..3f89acb 100644
--- a/frontend/db/backends/afe_sqlite/base.py
+++ b/frontend/db/backends/afe_sqlite/base.py
@@ -12,4 +12,7 @@ class DatabaseOperations(SQLiteDatabaseOperations):
 class DatabaseWrapper(SQLiteDatabaseWrapper):
     def __init__(self, *args, **kwargs):
         super(DatabaseWrapper, self).__init__(*args, **kwargs)
-        self.ops = DatabaseOperations()
+        try:
+            self.ops = DatabaseOperations()
+        except TypeError:
+            self.ops = DatabaseOperations(connection=kwargs.get('connection'))
-- 
1.7.10.2

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to