Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
erp5
Commits
2e3afafb
Commit
2e3afafb
authored
Mar 29, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Type.Core.Predicate: optimise test().
parent
7c8082a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
25 deletions
+27
-25
product/ERP5Type/Core/Predicate.py
product/ERP5Type/Core/Predicate.py
+27
-25
No files found.
product/ERP5Type/Core/Predicate.py
View file @
2e3afafb
...
@@ -139,34 +139,36 @@ class Predicate(XMLObject):
...
@@ -139,34 +139,36 @@ class Predicate(XMLObject):
# (result, property, value, max))
# (result, property, value, max))
if
not
result
:
if
not
result
:
return
result
return
result
multimembership_criterion_base_category_list
=
\
self
.
getMultimembershipCriterionBaseCategoryList
()
membership_criterion_base_category_list
=
\
self
.
getMembershipCriterionBaseCategoryList
()
tested_base_category
=
{}
# LOG('predicate test', 0,
# 'categories will be tested in multi %s single %s as %s' % \
# (multimembership_criterion_base_category_list,
# membership_criterion_base_category_list,
# self.getMembershipCriterionCategoryList()))
# Test category memberships. Enable the read-only transaction cache
# Test category memberships. Enable the read-only transaction cache
# because this part is strictly read-only, and context.isMemberOf
# because this part is strictly read-only, and context.isMemberOf
# is very expensive when the category list has many items.
# is very expensive when the category list has many items.
if
isMemberOf
is
None
:
membership_criterion_category_list
=
self
.
getMembershipCriterionCategoryList
()
isMemberOf
=
context
.
_getCategoryTool
().
isMemberOf
if
membership_criterion_category_list
:
with
readOnlyTransactionCache
():
multimembership_criterion_base_category_list
=
\
for
c
in
self
.
getMembershipCriterionCategoryList
():
self
.
getMultimembershipCriterionBaseCategoryList
()
bc
=
c
.
split
(
'/'
,
1
)[
0
]
membership_criterion_base_category_list
=
\
if
tested_base_category_list
is
None
or
bc
in
tested_base_category_list
:
self
.
getMembershipCriterionBaseCategoryList
()
if
bc
in
multimembership_criterion_base_category_list
:
tested_base_category
=
{}
if
not
isMemberOf
(
context
,
c
,
strict_membership
=
strict_membership
):
# LOG('predicate test', 0,
return
0
# 'categories will be tested in multi %s single %s as %s' % \
elif
bc
in
membership_criterion_base_category_list
and
\
# (multimembership_criterion_base_category_list,
not
tested_base_category
.
get
(
bc
):
# membership_criterion_base_category_list,
tested_base_category
[
bc
]
=
\
# self.getMembershipCriterionCategoryList()))
isMemberOf
(
context
,
c
,
strict_membership
=
strict_membership
)
if
isMemberOf
is
None
:
if
0
in
tested_base_category
.
itervalues
():
isMemberOf
=
context
.
_getCategoryTool
().
isMemberOf
return
0
with
readOnlyTransactionCache
():
for
c
in
membership_criterion_category_list
:
bc
=
c
.
split
(
'/'
,
1
)[
0
]
if
tested_base_category_list
is
None
or
bc
in
tested_base_category_list
:
if
bc
in
multimembership_criterion_base_category_list
:
if
not
isMemberOf
(
context
,
c
,
strict_membership
=
strict_membership
):
return
0
elif
bc
in
membership_criterion_base_category_list
and
\
not
tested_base_category
.
get
(
bc
):
tested_base_category
[
bc
]
=
\
isMemberOf
(
context
,
c
,
strict_membership
=
strict_membership
)
if
0
in
tested_base_category
.
itervalues
():
return
0
# Test method calls
# Test method calls
test_method_id_list
=
self
.
getTestMethodIdList
()
test_method_id_list
=
self
.
getTestMethodIdList
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment