Commit b5c7ce5c authored by Yoshinori Okuji's avatar Yoshinori Okuji

Re-connect if _v_database_connection disappears in sql_quote__.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37392 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 99190845
......@@ -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',)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment