Commit 89725905 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: return None in ZSQLBrain._aq_dynamic() if getObject() because of missing path.

in Python 2, _aq_dynamic() returns None without try..except but it raises ValueError in Python 3.

(python 2)
> /SR/parts/erp5/product/ZSQLCatalog/Extensions/zsqlbrain.py(31)_aq_dynamic()
 31  ->   def _aq_dynamic(self, name):
 32         """Acquire an attribute from a real object.
 33         """
 34         if name.startswith('__') :
 35           return None
 36         return getattr(self.getObject(), name, None)
((Pdb)) getattr(self.getObject(), name, None)
*** ValueError: Unable to getObject from ZSQLBrain if ZSQL Method does not retrieve the `path` column from catalog table.
((Pdb)) r
--Return--
> /SR/parts/erp5/product/ZSQLCatalog/Extensions/zsqlbrain.py(36)_aq_dynamic()->None # <-- !!!
Co-authored-by: Jérome Perrin's avatarJérome Perrin <jerome@nexedi.com>
parent 195bc384
......@@ -1568,8 +1568,8 @@ class SimulationTool(BaseTool):
try:
# We must copy the path so that getObject works
setattr(result, 'path', line_a.path)
except ValueError: # XXX: ValueError ? really ?
# getInventory return no object, so no path available
except (AttributeError, ValueError):
# getInventory returned no object, so no path available
pass
if parent is not None:
result = result.__of__(parent)
......
......@@ -33,7 +33,11 @@ class ZSQLBrain(Acquisition.Implicit):
"""
if name.startswith('__') :
return None
return getattr(self.getObject(), name, None)
try:
obj = self.getObject()
except ValueError:
return None
return getattr(obj, name, None)
def getURL(self):
return self.path
......
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