Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
Commits
73b6cf17
Commit
73b6cf17
authored
Dec 06, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache results of category membership when search searching for predicates
parent
5f023071
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
product/ERP5/Tool/DomainTool.py
product/ERP5/Tool/DomainTool.py
+20
-12
product/ERP5Type/Core/Predicate.py
product/ERP5Type/Core/Predicate.py
+8
-3
No files found.
product/ERP5/Tool/DomainTool.py
View file @
73b6cf17
...
...
@@ -242,18 +242,26 @@ class DomainTool(BaseTool):
if
kw
.
get
(
'src__'
):
return
sql_result_list
result_list
=
[]
for
predicate
in
sql_result_list
:
predicate
=
predicate
.
getObject
()
if
(
not
test
)
or
predicate
.
test
(
context
,
tested_base_category_list
=
tested_base_category_list
):
result_list
.
append
(
predicate
)
if
filter_method
is
not
None
:
result_list
=
filter_method
(
result_list
)
if
sort_key_method
is
not
None
:
result_list
.
sort
(
key
=
sort_key_method
)
elif
sort_method
is
not
None
:
result_list
.
sort
(
cmp
=
sort_method
)
if
sql_result_list
:
if
test
:
cache
=
{}
def
isMemberOf
(
context
,
c
,
strict_membership
):
if
c
in
cache
:
return
cache
[
c
]
cache
[
c
]
=
result
=
portal_categories
.
isMemberOf
(
context
,
c
,
strict_membership
=
strict_membership
)
return
result
for
predicate
in
sql_result_list
:
predicate
=
predicate
.
getObject
()
if
not
test
or
predicate
.
test
(
context
,
tested_base_category_list
,
isMemberOf
=
isMemberOf
):
result_list
.
append
(
predicate
)
if
filter_method
is
not
None
:
result_list
=
filter_method
(
result_list
)
if
sort_key_method
is
not
None
:
result_list
.
sort
(
key
=
sort_key_method
)
elif
sort_method
is
not
None
:
result_list
.
sort
(
cmp
=
sort_method
)
return
result_list
# XXX FIXME method should not be public
...
...
product/ERP5Type/Core/Predicate.py
View file @
73b6cf17
...
...
@@ -87,7 +87,7 @@ class Predicate(XMLObject):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'test'
)
def
test
(
self
,
context
,
tested_base_category_list
=
None
,
strict_membership
=
0
,
**
kw
):
strict_membership
=
0
,
isMemberOf
=
None
,
**
kw
):
"""
A Predicate can be tested on a given context.
Parameters can passed in order to ignore some conditions.
...
...
@@ -97,6 +97,9 @@ class Predicate(XMLObject):
destination or the source of a predicate.
- if strict_membership is specified, we should make sure that we
are strictly a member of tested categories
- isMemberOf can be a function caching results for
CategoryTool.isMemberOf: it is always called with given 'context' and
'strict_membership' values, and different categories.
"""
self
=
self
.
asPredicate
()
if
self
is
None
:
...
...
@@ -150,17 +153,19 @@ class Predicate(XMLObject):
# 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
:
isMemberOf
=
context
.
_getCategoryTool
().
isMemberOf
with
readOnlyTransactionCache
():
for
c
in
self
.
getMembershipCriterionCategoryList
():
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
context
.
isMemberOf
(
c
,
strict_membership
=
strict_membership
):
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
]
=
\
context
.
isMemberOf
(
c
,
strict_membership
=
strict_membership
)
isMemberOf
(
context
,
c
,
strict_membership
=
strict_membership
)
if
0
in
tested_base_category
.
itervalues
():
return
0
...
...
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