From 56a1f47d3ebb7c5d27efcbfdd07d165f080301d7 Mon Sep 17 00:00:00 2001 From: Kazuhiko SHIOZAKI <kazuhiko@nexedi.com> Date: Fri, 14 Oct 2022 21:27:01 +0200 Subject: [PATCH] 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 # <-- !!! --- product/ZSQLCatalog/Extensions/zsqlbrain.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/product/ZSQLCatalog/Extensions/zsqlbrain.py b/product/ZSQLCatalog/Extensions/zsqlbrain.py index 831358c1ab..fe02cdec66 100644 --- a/product/ZSQLCatalog/Extensions/zsqlbrain.py +++ b/product/ZSQLCatalog/Extensions/zsqlbrain.py @@ -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 -- 2.30.9