From 6a9058af77565b7393159e61154496afb7959af0 Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Fri, 9 Apr 2004 13:43:35 +0000 Subject: [PATCH] Prevent getSingleCategoryAcquiredMembershipList from acquiring infinitely. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@659 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/CMFCategory/CategoryTool.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/product/CMFCategory/CategoryTool.py b/product/CMFCategory/CategoryTool.py index 8bd775aa18..54c34e0f49 100755 --- a/product/CMFCategory/CategoryTool.py +++ b/product/CMFCategory/CategoryTool.py @@ -390,6 +390,7 @@ class CategoryTool( UniqueObject, Folder, Base ): base_category_list = self.getBaseCategoryList() else: base_category_list = base_category + #LOG('getCategoryChildItemList', 0, str(base_category_list)) if display_none_category: result = [('', '')] else: @@ -719,7 +720,7 @@ class CategoryTool( UniqueObject, Folder, Base ): security.declareProtected( Permissions.AccessContentsInformation, 'getSingleCategoryAcquiredMembershipList' ) def getSingleCategoryAcquiredMembershipList(self, context, base_category, base=0, - spec=(), filter=None, **kw ): + spec=(), filter=None, acquired_object_dict = None, **kw ): """ Returns the acquired membership of the context for a single base category represented as a list of relative URLs @@ -745,6 +746,9 @@ class CategoryTool( UniqueObject, Folder, Base ): #LOG("Get Acquired Category ",0,str((base_category, context))) # XXX We must use filters in the future # query = self._buildQuery(spec, filter, kw) + if acquired_object_dict is None: + acquired_object_dict = {} + portal_type = kw.get('portal_type', ()) if spec is (): spec = portal_type # This is bad XXX - JPS - spec is for meta_type, not for portal_type - be consistent ! @@ -800,14 +804,18 @@ class CategoryTool( UniqueObject, Folder, Base ): original_result = result result = list(result) # make a copy for my_acquisition_object in my_acquisition_object_list: - if my_acquisition_object is not None: + #LOG('getSingleCategoryAcquiredMembershipList', 0, 'my_acquisition_object = %s, acquired_object_dict = %s' % (str(my_acquisition_object), str(acquired_object_dict))) + #if my_acquisition_object is not None: + if my_acquisition_object is not None and my_acquisition_object not in acquired_object_dict: + acquired_object_dict[my_acquisition_object] = 1 if hasattr(my_acquisition_object, '_categories'): # We should only consider objects which define that category if base_category in my_acquisition_object._categories: if spec is () or my_acquisition_object.portal_type in spec: #LOG("Recursive call ",0,str(spec)) new_result = self.getSingleCategoryAcquiredMembershipList(my_acquisition_object, - base_category, spec=spec, filter=filter, portal_type=portal_type, base=base) + base_category, spec=spec, filter=filter, portal_type=portal_type, base=base, + acquired_object_dict=acquired_object_dict) else: #LOG("No recursive call ",0,str(spec)) new_result = [] -- 2.30.9