Commit f85c9689 authored by Jean-Paul Smets's avatar Jean-Paul Smets

faster detection of infinite loop in category acquisition


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@815 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5599aa0e
...@@ -754,15 +754,31 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -754,15 +754,31 @@ class CategoryTool( UniqueObject, Folder, Base ):
spec = [spec] spec = [spec]
if acquired_object_dict is None: if acquired_object_dict is None:
acquired_object_dict = {} acquired_object_dict = {}
else:
context_key = (tuple(context.getPhysicalPath()), base_category, tuple(spec)) # Prevents recursion in category acquisition context_base_key = (tuple(context.getPhysicalPath()), base_category)
if context_key in acquired_object_dict: if context_base_key in acquired_object_dict:
# Stop recursion if this object if already used type_dict = acquired_object_dict[context_base_key]
return [] if spec is ():
if () in type_dict:
return []
else:
type_dict[()] = 1
else:
for pt in spec:
if pt in type_dict:
return []
else:
type_dict[pt] = 1
else:
type_dict = {}
if spec is ():
type_dict[()] = 1
else: else:
acquired_object_dict[context_key] = 1 for pt in spec:
type_dict[pt] = 1
acquired_object_dict[context_base_key] = type_dict
result = self.getSingleCategoryMembershipList( context, base_category, base=base, result = self.getSingleCategoryMembershipList( context, base_category, base=base,
spec=spec, filter=filter, **kw ) spec=spec, filter=filter, **kw )
......
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