Commit 2e3afafb authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ERP5Type.Core.Predicate: optimise test().

parent 7c8082a2
...@@ -139,6 +139,11 @@ class Predicate(XMLObject): ...@@ -139,6 +139,11 @@ class Predicate(XMLObject):
# (result, property, value, max)) # (result, property, value, max))
if not result: if not result:
return result return result
# Test category memberships. Enable the read-only transaction cache
# because this part is strictly read-only, and context.isMemberOf
# is very expensive when the category list has many items.
membership_criterion_category_list = self.getMembershipCriterionCategoryList()
if membership_criterion_category_list:
multimembership_criterion_base_category_list = \ multimembership_criterion_base_category_list = \
self.getMultimembershipCriterionBaseCategoryList() self.getMultimembershipCriterionBaseCategoryList()
membership_criterion_base_category_list = \ membership_criterion_base_category_list = \
...@@ -149,13 +154,10 @@ class Predicate(XMLObject): ...@@ -149,13 +154,10 @@ class Predicate(XMLObject):
# (multimembership_criterion_base_category_list, # (multimembership_criterion_base_category_list,
# membership_criterion_base_category_list, # membership_criterion_base_category_list,
# self.getMembershipCriterionCategoryList())) # self.getMembershipCriterionCategoryList()))
# Test category memberships. Enable the read-only transaction cache
# because this part is strictly read-only, and context.isMemberOf
# is very expensive when the category list has many items.
if isMemberOf is None: if isMemberOf is None:
isMemberOf = context._getCategoryTool().isMemberOf isMemberOf = context._getCategoryTool().isMemberOf
with readOnlyTransactionCache(): with readOnlyTransactionCache():
for c in self.getMembershipCriterionCategoryList(): for c in membership_criterion_category_list:
bc = c.split('/', 1)[0] bc = c.split('/', 1)[0]
if tested_base_category_list is None or bc in tested_base_category_list: if tested_base_category_list is None or bc in tested_base_category_list:
if bc in multimembership_criterion_base_category_list: if bc in multimembership_criterion_base_category_list:
......
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