From 626605542c445af3e2787af37a8589bc8c441aa2 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Fri, 29 Feb 2008 14:37:13 +0000 Subject: [PATCH] revise the implementation of getting the root document path. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19592 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Base.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 1a9e1f0341..5a141b5fad 100644 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -2713,30 +2713,22 @@ class Base( CopyContainer, self.activate(group_method_id='portal_catalog/catalogObjectList', alternate_method_id='alternateReindexObject', group_id=group_id, - serialization_tag=self.getRootDocument(), + serialization_tag=self.getRootDocumentPath(), **activate_kw).immediateReindexObject(**kw) security.declarePublic('recursiveReindexObject') recursiveReindexObject = reindexObject - def getRootDocument(self): - result = self.getRootDocumentValue() - if result is not None: - result = result.getPath() - return result - - def getRootDocumentValue(self): - result = None - parent_value = self.getParentValue() - if parent_value is not None: - parent_id = parent_value.getId() - if parent_id.endswith('_module') or parent_id.startswith('portal_'): - result = self - else: - getRootDocumentValue = getattr(parent_value, 'getRootDocumentValue', None) - if getRootDocumentValue is not None: - result = getRootDocumentValue() - return result + def getRootDocumentPath(self): + # if document, return the path of its root document + # otherwire, return None + self_path_list = self.getPhysicalPath() + self_depth = len(self_path_list) + portal_depth = len(self.getPortalObject().getPhysicalPath()) + if self_depth > portal_depth + 1: + return '/'.join(self_path_list[:portal_depth + 2]) + else: + return None security.declareProtected( Permissions.AccessContentsInformation, 'getIndexableChildValueList' ) def getIndexableChildValueList(self): -- 2.30.9