Commit 8f9683ae authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Catalog.CatalogTool: Move "parent" base category special-casing out of loop.

Also, do not use getBaseCategoryDict to avoid mutating cached value and use
a set rather than a None-value dict.
Also, access portal_categories from portal explicitly rather than relying
on acquisition.
parent aa742887
......@@ -895,7 +895,10 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
the category.
"""
related_key_list = []
base_cat_id_list = self.portal_categories.getBaseCategoryDict()
base_cat_id_set = set(
self.getPortalObject().portal_categories.getBaseCategoryList()
)
base_cat_id_set.discard('parent')
default_string = 'default_'
strict_string = 'strict_'
related_string = 'related_'
......@@ -913,8 +916,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
split_key = key.split('_')
for i in xrange(len(split_key) - 1, 0, -1):
expected_base_cat_id = '_'.join(split_key[0:i])
if expected_base_cat_id != 'parent' and \
expected_base_cat_id in base_cat_id_list:
if expected_base_cat_id in base_cat_id_set:
# We have found a base_category
end_key = '_'.join(split_key[i:])
related = end_key.startswith(related_string)
......
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