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
94354614
Commit
94354614
authored
Jun 07, 2017
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CatalogTool: Add dynamic related key generation to predicate_category table
parent
2991c1f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
product/ERP5Catalog/CatalogTool.py
product/ERP5Catalog/CatalogTool.py
+11
-4
No files found.
product/ERP5Catalog/CatalogTool.py
View file @
94354614
...
@@ -71,11 +71,13 @@ SECURITY_QUERY_ARGUMENT_NAME = 'ERP5Catalog_security_query'
...
@@ -71,11 +71,13 @@ SECURITY_QUERY_ARGUMENT_NAME = 'ERP5Catalog_security_query'
DYNAMIC_RELATED_KEY_FLAG_PARENT
=
1
<<
0
DYNAMIC_RELATED_KEY_FLAG_PARENT
=
1
<<
0
DYNAMIC_RELATED_KEY_FLAG_STRICT
=
1
<<
1
DYNAMIC_RELATED_KEY_FLAG_STRICT
=
1
<<
1
DYNAMIC_RELATED_KEY_FLAG_PREDICATE
=
1
<<
2
# Note: parsing flags backward as "pop()" is O(1), so this list contains flags
# Note: parsing flags backward as "pop()" is O(1), so this list contains flags
# in right to left order.
# in right to left order.
DYNAMIC_RELATED_KEY_FLAG_LIST
=
(
DYNAMIC_RELATED_KEY_FLAG_LIST
=
(
(
'parent'
,
DYNAMIC_RELATED_KEY_FLAG_PARENT
),
(
'parent'
,
DYNAMIC_RELATED_KEY_FLAG_PARENT
),
(
'strict'
,
DYNAMIC_RELATED_KEY_FLAG_STRICT
),
(
'strict'
,
DYNAMIC_RELATED_KEY_FLAG_STRICT
),
(
'predicate'
,
DYNAMIC_RELATED_KEY_FLAG_PREDICATE
),
)
)
class
IndexableObjectWrapper
(
object
):
class
IndexableObjectWrapper
(
object
):
...
@@ -965,7 +967,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
...
@@ -965,7 +967,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
by looking at the category tree.
by looking at the category tree.
Syntax:
Syntax:
[[strict_][parent_]_]<base category id>__[related__]<column id>
[[predicate_][strict_][parent_]_]<base category id>__[related__]<column id>
"predicate": Use predicate_category as relation table, otherwise category table.
"strict": Match only strict relation members, otherwise match non-strict too.
"strict": Match only strict relation members, otherwise match non-strict too.
"parent": Search for documents whose parent have described relation, otherwise search for their immediate relations.
"parent": Search for documents whose parent have described relation, otherwise search for their immediate relations.
<base_category_id>: The id of an existing Base Category document, or "any" to not restrict by relation type.
<base_category_id>: The id of an existing Base Category document, or "any" to not restrict by relation type.
...
@@ -1041,7 +1044,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
...
@@ -1041,7 +1044,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
column_id
=
'uid'
if
related
else
'category_uid'
column_id
=
'uid'
if
related
else
'category_uid'
related_key_list
.
append
(
related_key_list
.
append
(
key
+
' | '
+
key
+
' | '
+
'category'
+
(
'predicate_'
if
flag_bitmap
&
DYNAMIC_RELATED_KEY_FLAG_PREDICATE
else
''
)
+
'category'
+
(
''
if
is_uid
else
',catalog'
)
+
(
''
if
is_uid
else
',catalog'
)
+
'/'
+
'/'
+
column_id
+
column_id
+
...
@@ -1054,13 +1057,15 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
...
@@ -1054,13 +1057,15 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
return
related_key_list
return
related_key_list
security
.
declarePublic
(
'getCategoryParameterDict'
)
security
.
declarePublic
(
'getCategoryParameterDict'
)
def
getCategoryParameterDict
(
self
,
category_list
,
strict_membership
=
True
,
forward
=
True
,
onMissing
=
lambda
category
:
True
):
def
getCategoryParameterDict
(
self
,
category_list
,
category_table
=
'category'
,
strict_membership
=
True
,
forward
=
True
,
onMissing
=
lambda
category
:
True
):
"""
"""
From a list of categories, produce a catalog keyword argument dictionary
From a list of categories, produce a catalog keyword argument dictionary
testing (strict or not, forward or reverse relation) membership to these
testing (strict or not, forward or reverse relation) membership to these
categories.
categories.
category_list (list of category relative urls with their base categories)
category_list (list of category relative urls with their base categories)
category_table ('category' or 'predicate_category')
Controls the table to use for membership lookup.
strict_membership (bool)
strict_membership (bool)
Whether intermediate relation members should be excluded (true) or
Whether intermediate relation members should be excluded (true) or
included (false).
included (false).
...
@@ -1078,7 +1083,9 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
...
@@ -1078,7 +1083,9 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
are sets of uids.
are sets of uids.
"""
"""
flag_list
=
[]
flag_list
=
[]
if
category_table
!=
'category'
:
if
category_table
==
'predicate_category'
:
flag_list
.
append
(
'predicate'
)
elif
category_table
!=
'category'
:
raise
ValueError
(
'Unknown category table %r'
%
(
category_table
,
))
raise
ValueError
(
'Unknown category table %r'
%
(
category_table
,
))
if
strict_membership
:
if
strict_membership
:
flag_list
.
append
(
'strict'
)
flag_list
.
append
(
'strict'
)
...
...
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