[Erp5-report] r37392 yo - /erp5/trunk/products/ZMySQLDA/DA.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Aug 2 07:10:59 CEST 2010


Author: yo
Date: Mon Aug  2 07:10:58 2010
New Revision: 37392

URL: http://svn.erp5.org?rev=37392&view=rev
Log:
Re-connect if _v_database_connection disappears in sql_quote__.

Modified:
    erp5/trunk/products/ZMySQLDA/DA.py

Modified: erp5/trunk/products/ZMySQLDA/DA.py
URL: http://svn.erp5.org/erp5/trunk/products/ZMySQLDA/DA.py?rev=37392&r1=37391&r2=37392&view=diff
==============================================================================
--- erp5/trunk/products/ZMySQLDA/DA.py [utf8] (original)
+++ erp5/trunk/products/ZMySQLDA/DA.py [utf8] Mon Aug  2 07:10:58 2010
@@ -155,7 +155,17 @@ class Connection(DABase.Connection):
       return self
 
     def sql_quote__(self, v, escapes={}):
-        return self._v_database_connection.string_literal(v)
+        try:
+            connection = self._v_database_connection
+        except AttributeError:
+            # The volatile attribute sometimes disappears.
+            # In this case, re-assign it by calling the connect method.
+            # Note that we don't call sql_quote__ recursively by intention,
+            # because if connect fails to assign the volatile attribute for
+            # any reason, that would generate an infinite loop.
+            self.connect(self.connection_string)
+            connection = self._v_database_connection
+        return connection.string_literal(v)
 
 
 classes=('DA.Connection',)




More information about the Erp5-report mailing list