From 2dc7d1467b18801f7f429849bad5121095d1d556 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Thu, 18 Mar 2010 11:10:43 +0000 Subject: [PATCH] * Move recursive_path_list filling after installation because some objects may have been deleted. * Check that objectIds() is supported on object before calling it. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33857 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/BusinessTemplate.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index eeaeb114e9..0125436f8b 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -903,16 +903,6 @@ class ObjectTemplateItem(BaseTemplateItem): groups = {} old_groups = {} portal = context.getPortalObject() - # Fetch all sub objects path recursively - recursive_path_list = [] - def fillRecursivePathList(from_path_list): - for from_path in from_path_list: - container = portal.unrestrictedTraverse(from_path, None) - if container is not None: - recursive_path_list.append(from_path) - fillRecursivePathList(['%s/%s' % (from_path, sub_content_id) for\ - sub_content_id in container.objectIds()]) - fillRecursivePathList(self._objects.keys()) # sort to add objects before their subobjects keys = self._objects.keys() keys.sort() @@ -1129,6 +1119,18 @@ class ObjectTemplateItem(BaseTemplateItem): # restore previous activities execution order context.setPlacelessDefaultReindexParameters(**original_reindex_parameters) # Do not forget to delete all remaining objects if asked by user + # Fetch all sub objects path recursively + recursive_path_list = [] + def fillRecursivePathList(from_path_list): + for from_path in from_path_list: + container = portal.unrestrictedTraverse(from_path, None) + if container is not None: + recursive_path_list.append(from_path) + # Check that container support iteration of sub_content_id + if getattr(aq_base(container), 'objectIds', None) is not None: + fillRecursivePathList(['%s/%s' % (from_path, sub_content_id) for\ + sub_content_id in container.objectIds()]) + fillRecursivePathList(self._objects.keys()) for recursive_path in recursive_path_list: if recursive_path in update_dict: action = update_dict[recursive_path] -- 2.30.9