[PATCH 2/6] afe/readonly connection: Catch AttributeError exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Django 1.3, the DB connection object does not have some
of the attributes we are trying to compare on the __neq__
method, resulting on an AttributeError. Let's catch that
error so the application works under 1.3.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 frontend/afe/readonly_connection.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/frontend/afe/readonly_connection.py b/frontend/afe/readonly_connection.py
index 7d59aae..68af56c 100644
--- a/frontend/afe/readonly_connection.py
+++ b/frontend/afe/readonly_connection.py
@@ -89,7 +89,15 @@ class ReadOnlyConnection(object):
 
     def close(self):
         if self._connection is not None:
-            assert django_connection != self._connection
+            # Here we are checking if connection can be compared with
+            # the django DB class, but the connection class under django
+            # 1.3 doesn't have a settings_dict attribute, generating an
+            # AttributeError. So if that error is raised, supress it and
+            # only let the AssertionError pass.
+            try:
+                assert django_connection != self._connection
+            except AttributeError:
+                pass
             self._connection.close()
             self._connection = None
 
-- 
1.7.5.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux