Commit 5f2997fb authored by Arnaud Fontaine's avatar Arnaud Fontaine

Fix inconsistency when checking whether spec is empty (used to only

consider that this is a tuple whereas it could also be a list)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40752 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0f31cf42
...@@ -557,6 +557,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -557,6 +557,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
category_list = base_category category_list = base_category
if not isinstance(spec, (tuple, list)): if not isinstance(spec, (tuple, list)):
spec = [spec] spec = [spec]
spec_len = len(spec)
for path in self._getCategoryList(context): for path in self._getCategoryList(context):
# LOG('getCategoryMembershipList',0,str(path)) # LOG('getCategoryMembershipList',0,str(path))
my_base_category = path.split('/', 1)[0] my_base_category = path.split('/', 1)[0]
...@@ -566,7 +567,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -566,7 +567,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
else: else:
category = my_category.getRelativeUrl() category = my_category.getRelativeUrl()
if my_base_category == category: if my_base_category == category:
if spec is (): if spec_len == 0:
if base: if base:
membership.append(path) membership.append(path)
else: else:
...@@ -653,6 +654,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -653,6 +654,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
new_category_list = [] new_category_list = []
default_dict = {} default_dict = {}
spec_len = len(spec)
for path in self._getCategoryList(context): for path in self._getCategoryList(context):
my_base_id = self.getBaseCategoryId(path) my_base_id = self.getBaseCategoryId(path)
if my_base_id not in base_category_list: if my_base_id not in base_category_list:
...@@ -661,10 +663,10 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -661,10 +663,10 @@ class CategoryTool( UniqueObject, Folder, Base ):
new_category_list.append(path) new_category_list.append(path)
else: else:
keep_it = 0 keep_it = 0
if (spec is not ()) or (checked_permission is not None): if spec_len != 0 or (checked_permission is not None):
obj = self.unrestrictedTraverse(path, None) obj = self.unrestrictedTraverse(path, None)
if obj is not None: if obj is not None:
if spec is not (): if spec_len != 0:
# If spec is (), then we should keep nothing # If spec is (), then we should keep nothing
# Everything will be replaced # Everything will be replaced
# If spec is not (), Only keep this if not in our spec # If spec is not (), Only keep this if not in our spec
...@@ -816,6 +818,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -816,6 +818,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
# Make sure spec is a list or tuple # Make sure spec is a list or tuple
if isinstance(spec, str): if isinstance(spec, str):
spec = [spec] spec = [spec]
spec_len = len(spec)
# Filter categories # Filter categories
if getattr(aq_base(context), 'categories', _marker) is not _marker: if getattr(aq_base(context), 'categories', _marker) is not _marker:
...@@ -830,7 +833,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -830,7 +833,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
# my_base_category, base_category, category_url)) # my_base_category, base_category, category_url))
if (checked_permission is None) or \ if (checked_permission is None) or \
(permissionFilter(category_url) is not None): (permissionFilter(category_url) is not None):
if spec is (): if spec_len == 0:
if base: if base:
append(category_url) append(category_url)
else: else:
......
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