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
1
Merge Requests
1
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
Cédric Le Ninivin
erp5
Commits
d8dfa6c7
Commit
d8dfa6c7
authored
Jun 11, 2017
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CategoryTool: Factorise out-of-ZODB related object lookup
To prepare for extension.
parent
87ab190b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
15 deletions
+7
-15
product/CMFCategory/CategoryTool.py
product/CMFCategory/CategoryTool.py
+7
-15
No files found.
product/CMFCategory/CategoryTool.py
View file @
d8dfa6c7
...
@@ -1364,10 +1364,10 @@ class CategoryTool( UniqueObject, Folder, Base ):
...
@@ -1364,10 +1364,10 @@ class CategoryTool( UniqueObject, Folder, Base ):
category_list
.
append
(
"%s/%s"
%
(
base_category
,
relative_url
))
category_list
.
append
(
"%s/%s"
%
(
base_category
,
relative_url
))
search
=
self
.
getPortalObject
().
Base_zSearchRelatedObjectsByCategoryList
search
=
self
.
getPortalObject
().
Base_zSearchRelatedObjectsByCategoryList
result_dict
=
{}
if
local_index_dict
:
if
local_index_dict
:
# For some base categories, lookup indexes in ZODB.
# For some base categories, lookup indexes in ZODB.
recurse
=
isinstance
(
context
,
Category
)
and
not
strict_membership
recurse
=
isinstance
(
context
,
Category
)
and
not
strict_membership
result_dict
=
{}
def
check_local
():
def
check_local
():
r
=
set
(
getattr
(
related
,
base_category
,
()))
r
=
set
(
getattr
(
related
,
base_category
,
()))
r
.
difference_update
(
result_dict
)
r
.
difference_update
(
result_dict
)
...
@@ -1456,22 +1456,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
...
@@ -1456,22 +1456,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
not
portal_type
or
ob
.
getPortalType
()
in
portal_type
)]
not
portal_type
or
ob
.
getPortalType
()
in
portal_type
)]
# Finish with base categories that are only indexed in catalog,
# Finish with base categories that are only indexed in catalog,
# making sure we don't return duplicate values.
# making sure we don't return duplicate values.
if
category_list
:
for
r
in
search
(
category_list
=
category_list
,
portal_type
=
portal_type
,
strict_membership
=
strict_membership
):
if
r
.
relative_url
not
in
result_dict
:
try
:
result
.
append
(
self
.
unrestrictedTraverse
(
r
.
path
))
except
KeyError
:
pass
else
:
else
:
# Catalog-only search.
# Catalog-only search.
result
=
[]
result
=
[]
if
category_list
:
for
r
in
search
(
category_list
=
category_list
,
for
r
in
search
(
category_list
=
category_list
,
portal_type
=
portal_type
,
portal_type
=
portal_type
,
strict_membership
=
strict_membership
):
strict_membership
=
strict_membership
):
if
r
.
relative_url
not
in
result_dict
:
try
:
try
:
result
.
append
(
self
.
unrestrictedTraverse
(
r
.
path
))
result
.
append
(
self
.
unrestrictedTraverse
(
r
.
path
))
except
KeyError
:
except
KeyError
:
...
...
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