Commit 6bef463e authored by iv's avatar iv

ERP5Workflow: fix acquisition on values got by getattr

parent 22754773
...@@ -36,12 +36,10 @@ class ERP5PersistentMappingFolder(PortalFolderBase): ...@@ -36,12 +36,10 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
def __getattr__(self, name): def __getattr__(self, name):
if self._object_dict is None: if self._object_dict is None:
LOG("### self._object_dict is None", 0, '')
raise AttributeError(name) raise AttributeError(name)
try: try:
return self._object_dict[name] return self._object_dict[name].__of__(self)
except KeyError: except KeyError:
LOG("### KeyError for key " + name + " not in:", 0, self._object_dict)
raise AttributeError(name) raise AttributeError(name)
def __len__(self): def __len__(self):
...@@ -60,6 +58,8 @@ class ERP5PersistentMappingFolder(PortalFolderBase): ...@@ -60,6 +58,8 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
self._object_dict[object_id] = object_value self._object_dict[object_id] = object_value
def _delOb(self, object_id): def _delOb(self, object_id):
if self._object_dict is None:
raise KeyError, object_id
del self._object_dict[object_id] del self._object_dict[object_id]
def _getOb(self, object_id, default=_marker): def _getOb(self, object_id, default=_marker):
...@@ -77,6 +77,8 @@ class ERP5PersistentMappingFolder(PortalFolderBase): ...@@ -77,6 +77,8 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
def objectIds(self, spec=None, **kw): def objectIds(self, spec=None, **kw):
# we don't plan to use meta_type now, so spec is just here for compatibility # we don't plan to use meta_type now, so spec is just here for compatibility
assert(spec is None) assert(spec is None)
if self._object_dict is None:
return []
return self._object_dict.keys() return self._object_dict.keys()
def objectCount(self): def objectCount(self):
...@@ -84,7 +86,7 @@ class ERP5PersistentMappingFolder(PortalFolderBase): ...@@ -84,7 +86,7 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
def objectItems(self, spec=None): def objectItems(self, spec=None):
assert(spec is None) assert(spec is None)
return self._object_dict return self._object_dict.items()
def objectIds_d(self, t=None): def objectIds_d(self, t=None):
assert(t is None) assert(t is None)
...@@ -97,7 +99,12 @@ class ERP5PersistentMappingFolder(PortalFolderBase): ...@@ -97,7 +99,12 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
# Returns list of objects contained in this folder. # Returns list of objects contained in this folder.
# (no docstring to prevent publishing) # (no docstring to prevent publishing)
#assert(spec is None) #assert(spec is None)
if spec is not None:
if isinstance(spec, str):
spec = (spec,)
# hack to get the portal type for a specified meta_type
portal_type = [meta_type[5:] for meta_type in spec
if meta_type.startswith('ERP5 ')]
if self._object_dict is None: if self._object_dict is None:
return [] return []
......
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