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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Gambier
erp5
Commits
3365eecf
Commit
3365eecf
authored
Dec 12, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using Domain Tool to get list of applicable rules, to speed up 'expand'
parent
7e0a0fbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
product/ERP5/Tool/RuleTool.py
product/ERP5/Tool/RuleTool.py
+24
-9
No files found.
product/ERP5/Tool/RuleTool.py
View file @
3365eecf
...
...
@@ -95,12 +95,25 @@ class RuleTool(BaseTool):
- Predicate criterions can be used (like start_date_range_min)
"""
portal
=
self
.
getPortalObject
()
# XXX: For performance reasons, current implementation does not use
# DomainTool._searchPredicateList anymore, because in most cases, it
# does not filter anything before actualling calling Predicate.test()
# Properties must be added on rules to minimize the number of test
# scripts/expressions, like the portal types of the possible parent
# applied rules, so that filtering can be done via the catalog.
# Then it would be possible to use Domain Tool again.
#return portal.domain_tool._searchPredicateList(context=movement,
# tested_base_category_list=tested_base_category_list,
# portal_type=portal.getPortalRuleTypeList(),
# validation_state="validated", **kw) #XXX "validated" is hardcoded
# Most rules are only configured through their test_method_id,
# so filter out them quickly before
invoking slow searchPredicateList.
rule_
uid_
list
=
[]
# so filter out them quickly before
calling Predicate.test()
rule_list
=
[]
for
rule
in
portal
.
portal_catalog
.
unrestrictedSearchResults
(
portal_type
=
portal
.
getPortalRuleTypeList
(),
validation_state
=
"validated"
):
#XXX "validated" is hardcoded
validation_state
=
"validated"
,
**
kw
):
#XXX "validated" is hardcoded
rule
=
rule
.
getObject
()
try
:
for
test_method_id
in
rule
.
getTestMethodIdList
():
...
...
@@ -108,17 +121,19 @@ class RuleTool(BaseTool):
not
getattr
(
movement
,
test_method_id
)(
rule
):
break
else
:
rule_uid_list
.
append
(
rule
.
getUid
())
if
rule
.
test
(
movement
,
tested_base_category_list
=
tested_base_category_list
):
rule_list
.
append
(
rule
)
except
Exception
:
# Maybe the script is old (= it takes no argument). Or we should not
# have called it (= rule would have been excluded before, depending
# on other criterions). Or there may be a bug.
# We don't know why it failed so let searchPredicateList do the work.
rule_uid_list
.
append
(
rule
.
getUid
())
# We don't know why it failed so let Predicate.test() do the work.
if
rule
.
test
(
movement
,
tested_base_category_list
=
tested_base_category_list
):
rule_list
.
append
(
rule
)
return
rule_uid_list
and
portal
.
portal_domains
.
_searchPredicateList
(
context
=
movement
,
uid
=
rule_uid_list
,
tested_base_category_list
=
tested_base_category_list
,
**
kw
)
return
rule_list
InitializeClass
(
RuleTool
)
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