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
4711e761
Commit
4711e761
authored
Apr 29, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Catalog.CatalogTool: Do not join with catalog when condition is on uid.
Also, factorise related key string generation.
parent
566c4bb6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
product/ERP5Catalog/CatalogTool.py
product/ERP5Catalog/CatalogTool.py
+27
-14
No files found.
product/ERP5Catalog/CatalogTool.py
View file @
4711e761
...
...
@@ -264,13 +264,21 @@ class RelatedBaseCategory(Method):
'foreign_side'
:
foreign_side
,
'query_table_side'
:
query_table_side
,
}
self
.
_monotable_template
=
"""
\
%%(category_table)s.base_category_uid = %%(base_category_uid)s
%(strict)sAND %%(category_table)s.%(query_table_side)s = %%(query_table)s.uid"""
%
{
'strict'
:
strict
,
'query_table_side'
:
query_table_side
,
}
def
__call__
(
self
,
instance
,
table_0
,
table_1
,
query_table
=
'catalog'
,
def
__call__
(
self
,
instance
,
table_0
,
table_1
=
None
,
query_table
=
'catalog'
,
RELATED_QUERY_SEPARATOR
=
' AND '
,
**
kw
):
"""Create the sql code for this related key."""
# Note: in normal conditions, our category's uid will not change from
# one invocation to the next.
return
self
.
_template
%
{
return
(
self
.
_monotable_template
if
table_1
is
None
else
self
.
_template
)
%
{
'base_category_uid'
:
instance
.
getPortalObject
().
portal_categories
.
\
_getOb
(
self
.
_id
).
getUid
(),
'query_table'
:
query_table
,
...
...
@@ -884,6 +892,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
base_cat_id_list
=
self
.
portal_categories
.
getBaseCategoryDict
()
default_string
=
'default_'
strict_string
=
'strict_'
related_string
=
'related_'
for
key
in
key_list
:
prefix
=
''
strict
=
0
...
...
@@ -903,22 +912,26 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
expected_base_cat_id
in
base_cat_id_list
:
# We have found a base_category
end_key
=
'_'
.
join
(
splitted_key
[
i
:])
if
end_key
.
startswith
(
'related_'
):
end_key
=
end_key
[
len
(
'related_'
):]
suffix
=
'_related'
else
:
suffix
=
''
related
=
end_key
.
startswith
(
related_string
)
if
related
:
end_key
=
end_key
[
len
(
related_string
):]
# accept only some catalog columns
if
end_key
in
(
'title'
,
'uid'
,
'description'
,
'reference'
,
'relative_url'
,
'id'
,
'portal_type'
,
'simulation_state'
):
if
strict
:
pattern
=
'%s%s | category,catalog/%s/z_related_strict_%s%s'
else
:
pattern
=
'%s%s | category,catalog/%s/z_related_%s%s'
related_key_list
.
append
(
pattern
%
(
prefix
,
key
,
end_key
,
expected_base_cat_id
,
suffix
))
is_uid
=
end_key
==
'uid'
if
is_uid
:
end_key
=
'uid'
if
related
else
'category_uid'
related_key_list
.
append
(
prefix
+
key
+
' | category'
+
(
''
if
is_uid
else
',catalog'
)
+
'/'
+
end_key
+
'/z_related_'
+
(
'strict_'
if
strict
else
''
)
+
expected_base_cat_id
+
(
'_related'
if
related
else
''
)
)
return
related_key_list
...
...
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