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
alecs_myu
erp5
Commits
77d94dd5
Commit
77d94dd5
authored
Dec 08, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up RuleTool.searchRuleList by quickly filtering out rules
parent
1cea9468
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
9 deletions
+25
-9
product/ERP5/Tool/RuleTool.py
product/ERP5/Tool/RuleTool.py
+25
-9
No files found.
product/ERP5/Tool/RuleTool.py
View file @
77d94dd5
...
...
@@ -30,8 +30,6 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
from
Products.ERP5Type
import
Permissions
from
Products.CMFCore.utils
import
getToolByName
from
Products.ERP5
import
_dtmldir
class
RuleTool
(
BaseTool
):
...
...
@@ -96,13 +94,31 @@ class RuleTool(BaseTool):
- the rule must be of a known portal type
- Predicate criterions can be used (like start_date_range_min)
"""
domain_tool
=
getToolByName
(
self
.
getPortalObject
(),
"portal_domains"
)
rule_list
=
domain_tool
.
searchPredicateList
(
context
=
movement
,
tested_base_category_list
=
tested_base_category_list
,
portal_type
=
self
.
getPortalRuleTypeList
(),
validation_state
=
"validated"
,
**
kw
)
#XXX "validated" is hardcoded
portal
=
self
.
getPortalObject
()
# Most rules are only configured through their test_method_id,
# so filter out them quickly before invoking slow searchPredicateList.
rule_uid_list
=
[]
for
rule
in
portal
.
portal_catalog
.
unrestrictedSearchResults
(
portal_type
=
portal
.
getPortalRuleTypeList
(),
validation_state
=
"validated"
,
**
kw
):
#XXX "validated" is hardcoded
rule
=
rule
.
getObject
()
try
:
for
test_method_id
in
rule
.
getTestMethodIdList
():
if
test_method_id
==
'Rule_testFalse'
or
\
not
getattr
(
movement
,
test_method_id
)(
rule
):
break
else
:
rule_uid_list
.
append
(
rule
.
getUid
())
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
())
return
rule_uid_list
and
portal
.
portal_domains
.
searchPredicateList
(
context
=
movement
,
uid
=
rule_uid_list
,
tested_base_category_list
=
tested_base_category_list
)
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