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
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
Tomáš Peterka
erp5
Commits
9e84b6ac
Commit
9e84b6ac
authored
Dec 08, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small optimization of DomainTool.searchPredicateList
parent
77d94dd5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
39 deletions
+20
-39
product/ERP5/Tool/DomainTool.py
product/ERP5/Tool/DomainTool.py
+20
-39
No files found.
product/ERP5/Tool/DomainTool.py
View file @
9e84b6ac
...
@@ -106,32 +106,19 @@ class DomainTool(BaseTool):
...
@@ -106,32 +106,19 @@ class DomainTool(BaseTool):
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
portal_catalog
=
portal
.
portal_catalog
portal_categories
=
portal
.
portal_categories
portal_categories
=
portal
.
portal_categories
portal_preferences
=
portal
.
portal_preferences
# Search the columns of the predicate table
# Search the columns of the predicate table
column_list
=
[
x
.
split
(
'.'
)[
1
]
for
x
in
portal_catalog
.
getColumnIds
()
range_column_set
=
set
()
if
x
.
startswith
(
'predicate.'
)]
query_list
=
[]
if
query
is
None
else
[
query
]
expression_list
=
[]
for
column
in
portal_catalog
.
getColumnIds
():
checked_column_list
=
[]
if
column
[:
10
]
==
'predicate.'
and
\
sql_kw
=
{}
column
[
-
10
:]
in
(
'_range_min'
,
'_range_max'
):
query_list
=
[]
property_name
=
column
[
10
:
-
10
]
if
query
is
not
None
:
if
property_name
not
in
range_column_set
:
query_list
=
[
query
]
range_column_set
.
add
(
property_name
)
for
column
in
column_list
:
if
column
not
in
checked_column_list
:
range_property
=
0
if
(
column
.
endswith
(
'_range_min'
))
or
\
(
column
.
endswith
(
'_range_max'
)):
range_property
=
1
property_name
=
column
[:
-
len
(
'_range_min'
)]
if
(
'%s_range_min'
%
column
)
in
column_list
:
range_property
=
1
property_name
=
column
if
range_property
:
# We have to check a range property
# We have to check a range property
equality
=
'predicate.
%s'
%
property_name
equality
=
'predicate.
'
+
property_name
range_min
=
'predicate.%s_range_min'
%
property_name
range_min
=
equality
+
'_range_min'
range_max
=
'predicate.%s_range_max'
%
property_name
range_max
=
equality
+
'_range_max'
value
=
context
.
getProperty
(
property_name
)
value
=
context
.
getProperty
(
property_name
)
...
@@ -166,10 +153,6 @@ class DomainTool(BaseTool):
...
@@ -166,10 +153,6 @@ class DomainTool(BaseTool):
query_list
.
append
(
query
)
query_list
.
append
(
query
)
checked_column_list
.
append
(
'%s'
%
property_name
)
checked_column_list
.
append
(
'%s_range_min'
%
property_name
)
checked_column_list
.
append
(
'%s_range_max'
%
property_name
)
# Add category selection
# Add category selection
if
tested_base_category_list
is
None
:
if
tested_base_category_list
is
None
:
if
acquired
:
if
acquired
:
...
@@ -187,11 +170,11 @@ class DomainTool(BaseTool):
...
@@ -187,11 +170,11 @@ class DomainTool(BaseTool):
extend
(
getter
(
tested_base_category
,
base
=
1
))
extend
(
getter
(
tested_base_category
,
base
=
1
))
if
tested_base_category_list
!=
[]:
if
tested_base_category_list
!=
[]:
preferred_predicate_category_list
=
portal_preferences
.
getPreferredPredicateCategoryList
()
preferred_predicate_category_list
=
portal
.
portal
_preferences
.
getPreferredPredicateCategoryList
()
if
(
preferred_predicate_category_list
and
if
(
preferred_predicate_category_list
and
tested_base_category_list
is
not
None
and
tested_base_category_list
is
not
None
and
set
(
preferred_predicate_category_list
).
issuperset
(
set
(
tested_base_category_list
)
)):
set
(
preferred_predicate_category_list
).
issuperset
(
tested_base_category_list
)):
# New behavior is enabled only if preferred predicate category is
# New behavior is enabled only if preferred predicate category is
# defined and tested_base_category_list is passed.
# defined and tested_base_category_list is passed.
predicate_category_query_list
=
[]
predicate_category_query_list
=
[]
...
@@ -230,24 +213,21 @@ class DomainTool(BaseTool):
...
@@ -230,24 +213,21 @@ class DomainTool(BaseTool):
query_list
.
append
(
predicate_category_query
)
query_list
.
append
(
predicate_category_query
)
else
:
else
:
# Traditional behavior
# Traditional behavior
if
len
(
category_list
)
==
0
:
category_list
=
[
'NULL'
]
category_expression_dict
=
portal_categories
.
buildAdvancedSQLSelector
(
category_expression_dict
=
portal_categories
.
buildAdvancedSQLSelector
(
category_list
,
category_list
or
[
'NULL'
]
,
query_table
=
'predicate_category'
,
query_table
=
'predicate_category'
,
none_sql_value
=
0
,
none_sql_value
=
0
,
strict
=
strict
)
strict
=
strict
)
where_expression
=
category_expression_dict
[
'where_expression'
]
where_expression
=
category_expression_dict
[
'where_expression'
]
if
where_expression
:
if
where_expression
:
sql_
kw
[
'where_expression'
]
=
SQLQuery
(
where_expression
)
kw
[
'where_expression'
]
=
SQLQuery
(
where_expression
)
if
'from_expression'
in
category_expression_dict
:
if
'from_expression'
in
category_expression_dict
:
sql_
kw
[
'from_expression'
]
=
category_expression_dict
[
'from_expression'
]
kw
[
'from_expression'
]
=
category_expression_dict
[
'from_expression'
]
else
:
else
:
# Add predicate_category.uid for automatic join
# Add predicate_category.uid for automatic join
sql_
kw
[
'predicate_category.uid'
]
=
'!=NULL'
kw
[
'predicate_category.uid'
]
=
'!=NULL'
kw
.
update
(
sql_kw
)
if
query_list
:
if
query_list
:
kw
[
'query'
]
=
ComplexQuery
(
logical_operator
=
'AND'
,
*
query_list
)
kw
[
'query'
]
=
ComplexQuery
(
logical_operator
=
'AND'
,
*
query_list
)
...
@@ -255,7 +235,8 @@ class DomainTool(BaseTool):
...
@@ -255,7 +235,8 @@ class DomainTool(BaseTool):
if
kw
.
get
(
'src__'
):
if
kw
.
get
(
'src__'
):
return
sql_result_list
return
sql_result_list
result_list
=
[]
result_list
=
[]
for
predicate
in
[
x
.
getObject
()
for
x
in
sql_result_list
]:
for
predicate
in
sql_result_list
:
predicate
=
predicate
.
getObject
()
if
(
not
test
)
or
predicate
.
test
(
if
(
not
test
)
or
predicate
.
test
(
context
,
context
,
tested_base_category_list
=
tested_base_category_list
):
tested_base_category_list
=
tested_base_category_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