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
amrani
erp5
Commits
27f4b03d
Commit
27f4b03d
authored
Jun 30, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZSQLCatalog: Drop explicit profiling integration.
Use pprofile instead for your profiling needs.
parent
f5dc6ca9
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
3 additions
and
163 deletions
+3
-163
product/ZSQLCatalog/ColumnMap.py
product/ZSQLCatalog/ColumnMap.py
+0
-12
product/ZSQLCatalog/Operator/ComparisonOperator.py
product/ZSQLCatalog/Operator/ComparisonOperator.py
+1
-8
product/ZSQLCatalog/Operator/OperatorBase.py
product/ZSQLCatalog/Operator/OperatorBase.py
+0
-12
product/ZSQLCatalog/Query/AutoQuery.py
product/ZSQLCatalog/Query/AutoQuery.py
+0
-7
product/ZSQLCatalog/Query/ComplexQuery.py
product/ZSQLCatalog/Query/ComplexQuery.py
+0
-7
product/ZSQLCatalog/Query/EntireQuery.py
product/ZSQLCatalog/Query/EntireQuery.py
+0
-3
product/ZSQLCatalog/Query/RelatedQuery.py
product/ZSQLCatalog/Query/RelatedQuery.py
+0
-6
product/ZSQLCatalog/Query/SimpleQuery.py
product/ZSQLCatalog/Query/SimpleQuery.py
+1
-5
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+0
-47
product/ZSQLCatalog/SQLExpression.py
product/ZSQLCatalog/SQLExpression.py
+0
-16
product/ZSQLCatalog/SearchKey/DateTimeKey.py
product/ZSQLCatalog/SearchKey/DateTimeKey.py
+0
-10
product/ZSQLCatalog/SearchKey/FullTextKey.py
product/ZSQLCatalog/SearchKey/FullTextKey.py
+0
-3
product/ZSQLCatalog/SearchKey/RelatedKey.py
product/ZSQLCatalog/SearchKey/RelatedKey.py
+0
-7
product/ZSQLCatalog/SearchKey/SearchKey.py
product/ZSQLCatalog/SearchKey/SearchKey.py
+1
-11
product/ZSQLCatalog/SearchKey/SphinxSEFullTextKey.py
product/ZSQLCatalog/SearchKey/SphinxSEFullTextKey.py
+0
-2
product/ZSQLCatalog/SearchText/SearchTextParser.py
product/ZSQLCatalog/SearchText/SearchTextParser.py
+0
-7
No files found.
product/ZSQLCatalog/ColumnMap.py
View file @
27f4b03d
...
@@ -34,7 +34,6 @@ from interfaces.column_map import IColumnMap
...
@@ -34,7 +34,6 @@ from interfaces.column_map import IColumnMap
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
zope.interface
import
implements
from
zope.interface
import
implements
from
Products.ZSQLCatalog.interfaces.column_map
import
IColumnMap
from
Products.ZSQLCatalog.interfaces.column_map
import
IColumnMap
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
from
Products.ZSQLCatalog.TableDefinition
import
(
PlaceHolderTableDefinition
,
from
Products.ZSQLCatalog.TableDefinition
import
(
PlaceHolderTableDefinition
,
TableAlias
,
TableAlias
,
InnerJoin
,
InnerJoin
,
...
@@ -56,7 +55,6 @@ class ColumnMap(object):
...
@@ -56,7 +55,6 @@ class ColumnMap(object):
implements
(
IColumnMap
)
implements
(
IColumnMap
)
@
profiler_decorator
def
__init__
(
self
,
def
__init__
(
self
,
catalog_table_name
=
None
,
catalog_table_name
=
None
,
table_override_map
=
None
,
table_override_map
=
None
,
...
@@ -110,7 +108,6 @@ class ColumnMap(object):
...
@@ -110,7 +108,6 @@ class ColumnMap(object):
"Cannot do left_joins while forcing implicit join"
"Cannot do left_joins while forcing implicit join"
)
)
@
profiler_decorator
def
registerColumn
(
self
,
raw_column
,
group
=
DEFAULT_GROUP_ID
,
simple_query
=
None
):
def
registerColumn
(
self
,
raw_column
,
group
=
DEFAULT_GROUP_ID
,
simple_query
=
None
):
assert
' as '
not
in
raw_column
.
lower
()
assert
' as '
not
in
raw_column
.
lower
()
# Sanitize input: extract column from raw column (might contain COUNT, ...).
# Sanitize input: extract column from raw column (might contain COUNT, ...).
...
@@ -151,7 +148,6 @@ class ColumnMap(object):
...
@@ -151,7 +148,6 @@ class ColumnMap(object):
def
ignoreColumn
(
self
,
column
):
def
ignoreColumn
(
self
,
column
):
self
.
column_ignore_set
.
add
(
column
)
self
.
column_ignore_set
.
add
(
column
)
@
profiler_decorator
def
registerRelatedKey
(
self
,
related_column
,
column
):
def
registerRelatedKey
(
self
,
related_column
,
column
):
# XXX: should we store the group, or directly the table on which the column is mapped ?
# XXX: should we store the group, or directly the table on which the column is mapped ?
# The former avoids duplicating data, but requires one more lookup (group + column -> table)
# The former avoids duplicating data, but requires one more lookup (group + column -> table)
...
@@ -168,7 +164,6 @@ class ColumnMap(object):
...
@@ -168,7 +164,6 @@ class ColumnMap(object):
self
.
related_group_dict
[
group
]
=
related_column
self
.
related_group_dict
[
group
]
=
related_column
return
group
return
group
@
profiler_decorator
def
registerCatalog
(
self
):
def
registerCatalog
(
self
):
"""
"""
Register catalog as being in use in query, and aliased with its own
Register catalog as being in use in query, and aliased with its own
...
@@ -189,7 +184,6 @@ class ColumnMap(object):
...
@@ -189,7 +184,6 @@ class ColumnMap(object):
self
.
registerTable
(
self
.
catalog_table_name
)
self
.
registerTable
(
self
.
catalog_table_name
)
self
.
resolveTable
(
self
.
catalog_table_name
,
self
.
catalog_table_name
)
self
.
resolveTable
(
self
.
catalog_table_name
,
self
.
catalog_table_name
)
@
profiler_decorator
def
registerRelatedKeyColumn
(
self
,
related_column
,
position
,
group
):
def
registerRelatedKeyColumn
(
self
,
related_column
,
position
,
group
):
assert
group
in
self
.
related_group_dict
assert
group
in
self
.
related_group_dict
group
=
self
.
getRelatedKeyGroup
(
position
,
group
)
group
=
self
.
getRelatedKeyGroup
(
position
,
group
)
...
@@ -200,7 +194,6 @@ class ColumnMap(object):
...
@@ -200,7 +194,6 @@ class ColumnMap(object):
def
getRelatedKeyGroup
(
self
,
position
,
group
):
def
getRelatedKeyGroup
(
self
,
position
,
group
):
return
'%s_column_%s'
%
(
group
,
position
)
return
'%s_column_%s'
%
(
group
,
position
)
@
profiler_decorator
def
registerTable
(
self
,
table_name
,
alias
=
None
,
group
=
DEFAULT_GROUP_ID
):
def
registerTable
(
self
,
table_name
,
alias
=
None
,
group
=
DEFAULT_GROUP_ID
):
table_alias_dict
=
self
.
table_alias_dict
table_alias_dict
=
self
.
table_alias_dict
table_alias_key
=
(
group
,
table_name
)
table_alias_key
=
(
group
,
table_name
)
...
@@ -216,7 +209,6 @@ class ColumnMap(object):
...
@@ -216,7 +209,6 @@ class ColumnMap(object):
elif
alias
is
not
None
and
alias
!=
existing_value
:
elif
alias
is
not
None
and
alias
!=
existing_value
:
raise
ValueError
,
'Table %r for group %r is aliased as %r, can
\
'
t alias it now as %r'
%
(
table_name
,
group
,
existing_value
,
alias
)
raise
ValueError
,
'Table %r for group %r is aliased as %r, can
\
'
t alias it now as %r'
%
(
table_name
,
group
,
existing_value
,
alias
)
@
profiler_decorator
def
_mapColumns
(
self
,
column_table_map
,
table_usage_dict
,
column_name_set
,
group
,
vote_result_dict
):
def
_mapColumns
(
self
,
column_table_map
,
table_usage_dict
,
column_name_set
,
group
,
vote_result_dict
):
mapping_dict
=
{}
mapping_dict
=
{}
catalog_table_name
=
self
.
catalog_table_name
catalog_table_name
=
self
.
catalog_table_name
...
@@ -320,7 +312,6 @@ class ColumnMap(object):
...
@@ -320,7 +312,6 @@ class ColumnMap(object):
if
table_name
!=
catalog_table_name
:
if
table_name
!=
catalog_table_name
:
self
.
_addJoinTableForColumn
(
table_name
,
column_name
,
group
)
self
.
_addJoinTableForColumn
(
table_name
,
column_name
,
group
)
@
profiler_decorator
def
build
(
self
,
sql_catalog
):
def
build
(
self
,
sql_catalog
):
join_query_to_build_list
=
[]
join_query_to_build_list
=
[]
catalog_table_name
=
self
.
catalog_table_name
catalog_table_name
=
self
.
catalog_table_name
...
@@ -497,7 +488,6 @@ class ColumnMap(object):
...
@@ -497,7 +488,6 @@ class ColumnMap(object):
else
:
else
:
return
None
return
None
@
profiler_decorator
def
resolveColumn
(
self
,
column
,
table_name
,
group
=
DEFAULT_GROUP_ID
):
def
resolveColumn
(
self
,
column
,
table_name
,
group
=
DEFAULT_GROUP_ID
):
assert
group
in
self
.
registry
assert
group
in
self
.
registry
assert
column
in
self
.
registry
[
group
]
assert
column
in
self
.
registry
[
group
]
...
@@ -513,7 +503,6 @@ class ColumnMap(object):
...
@@ -513,7 +503,6 @@ class ColumnMap(object):
else
:
else
:
raise
ValueError
,
'Cannot remap a column to another table. column_map[%r] = %r, new = %r'
%
(
column_map_key
,
column_map
.
get
(
column_map_key
),
table_name
)
raise
ValueError
,
'Cannot remap a column to another table. column_map[%r] = %r, new = %r'
%
(
column_map_key
,
column_map
.
get
(
column_map_key
),
table_name
)
@
profiler_decorator
def
resolveTable
(
self
,
table_name
,
alias
,
group
=
DEFAULT_GROUP_ID
):
def
resolveTable
(
self
,
table_name
,
alias
,
group
=
DEFAULT_GROUP_ID
):
table_alias_key
=
(
group
,
table_name
)
table_alias_key
=
(
group
,
table_name
)
assert
table_alias_key
in
self
.
table_alias_dict
assert
table_alias_key
in
self
.
table_alias_dict
...
@@ -545,7 +534,6 @@ class ColumnMap(object):
...
@@ -545,7 +534,6 @@ class ColumnMap(object):
return
[]
return
[]
@
profiler_decorator
def
_addJoinTableForColumn
(
self
,
table_name
,
column
,
group
=
DEFAULT_GROUP_ID
):
def
_addJoinTableForColumn
(
self
,
table_name
,
column
,
group
=
DEFAULT_GROUP_ID
):
"""
"""
Declare given table as requiring to be joined with catalog table on uid.
Declare given table as requiring to be joined with catalog table on uid.
...
...
product/ZSQLCatalog/Operator/ComparisonOperator.py
View file @
27f4b03d
...
@@ -32,10 +32,9 @@ from OperatorBase import OperatorBase
...
@@ -32,10 +32,9 @@ from OperatorBase import OperatorBase
from
Products.ZSQLCatalog.SQLExpression
import
SQLExpression
from
Products.ZSQLCatalog.SQLExpression
import
SQLExpression
from
Products.ZSQLCatalog.interfaces.operator
import
IOperator
from
Products.ZSQLCatalog.interfaces.operator
import
IOperator
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
,
list_type_list
from
Products.ZSQLCatalog.SQLCatalog
import
list_type_list
class
ComparisonOperatorBase
(
OperatorBase
):
class
ComparisonOperatorBase
(
OperatorBase
):
@
profiler_decorator
def
asSQLExpression
(
self
,
column
,
value_list
,
only_group_columns
):
def
asSQLExpression
(
self
,
column
,
value_list
,
only_group_columns
):
"""
"""
In a Comparison Operator, rendering order is:
In a Comparison Operator, rendering order is:
...
@@ -53,7 +52,6 @@ class ComparisonOperatorBase(OperatorBase):
...
@@ -53,7 +52,6 @@ class ComparisonOperatorBase(OperatorBase):
verifyClass
(
IOperator
,
ComparisonOperatorBase
)
verifyClass
(
IOperator
,
ComparisonOperatorBase
)
class
MonovaluedComparisonOperator
(
ComparisonOperatorBase
):
class
MonovaluedComparisonOperator
(
ComparisonOperatorBase
):
@
profiler_decorator
def
renderValue
(
self
,
value_list
):
def
renderValue
(
self
,
value_list
):
"""
"""
value_list must either be a non-list or a single-value list.
value_list must either be a non-list or a single-value list.
...
@@ -65,7 +63,6 @@ class MonovaluedComparisonOperator(ComparisonOperatorBase):
...
@@ -65,7 +63,6 @@ class MonovaluedComparisonOperator(ComparisonOperatorBase):
raise
ValueError
,
'%r: value_list must not contain more than one item. Got %r'
%
(
self
,
value_list
)
raise
ValueError
,
'%r: value_list must not contain more than one item. Got %r'
%
(
self
,
value_list
)
return
self
.
_renderValue
(
value_list
)
return
self
.
_renderValue
(
value_list
)
@
profiler_decorator
def
render
(
self
,
column
,
value_list
):
def
render
(
self
,
column
,
value_list
):
"""
"""
value_list must either be a non-list or a single-value list.
value_list must either be a non-list or a single-value list.
...
@@ -80,7 +77,6 @@ class MonovaluedComparisonOperator(ComparisonOperatorBase):
...
@@ -80,7 +77,6 @@ class MonovaluedComparisonOperator(ComparisonOperatorBase):
verifyClass
(
IOperator
,
MonovaluedComparisonOperator
)
verifyClass
(
IOperator
,
MonovaluedComparisonOperator
)
class
MultivaluedComparisonOperator
(
ComparisonOperatorBase
):
class
MultivaluedComparisonOperator
(
ComparisonOperatorBase
):
@
profiler_decorator
def
renderValue
(
self
,
value_list
):
def
renderValue
(
self
,
value_list
):
"""
"""
value_list must be a multi-value list (more than one item).
value_list must be a multi-value list (more than one item).
...
@@ -89,7 +85,6 @@ class MultivaluedComparisonOperator(ComparisonOperatorBase):
...
@@ -89,7 +85,6 @@ class MultivaluedComparisonOperator(ComparisonOperatorBase):
raise
ValueError
,
'%r: value_list must be a list of more than one item. Got %r'
%
(
self
,
value_list
)
raise
ValueError
,
'%r: value_list must be a list of more than one item. Got %r'
%
(
self
,
value_list
)
return
'(%s)'
%
', '
.
join
(
map
(
self
.
_renderValue
,
value_list
))
return
'(%s)'
%
', '
.
join
(
map
(
self
.
_renderValue
,
value_list
))
@
profiler_decorator
def
render
(
self
,
column
,
value_list
):
def
render
(
self
,
column
,
value_list
):
"""
"""
value_list must be a multi-value list (more than one item).
value_list must be a multi-value list (more than one item).
...
@@ -105,7 +100,6 @@ class MatchComparisonOperator(MonovaluedComparisonOperator):
...
@@ -105,7 +100,6 @@ class MatchComparisonOperator(MonovaluedComparisonOperator):
MonovaluedComparisonOperator
.
__init__
(
self
,
operator
,
''
)
MonovaluedComparisonOperator
.
__init__
(
self
,
operator
,
''
)
self
.
where_expression_format_string
=
'MATCH (%%(column)s) AGAINST (%%(value_list)s%s)'
%
(
mode
,
)
self
.
where_expression_format_string
=
'MATCH (%%(column)s) AGAINST (%%(value_list)s%s)'
%
(
mode
,
)
@
profiler_decorator
def
asSQLExpression
(
self
,
column
,
value_list
,
only_group_columns
):
def
asSQLExpression
(
self
,
column
,
value_list
,
only_group_columns
):
"""
"""
This operator can emit a select expression, so it overrides
This operator can emit a select expression, so it overrides
...
@@ -150,7 +144,6 @@ class SphinxSEComparisonOperator(MonovaluedComparisonOperator):
...
@@ -150,7 +144,6 @@ class SphinxSEComparisonOperator(MonovaluedComparisonOperator):
value_list
=
'%s;mode=extended2;limit=1000'
%
value_list
value_list
=
'%s;mode=extended2;limit=1000'
%
value_list
return
self
.
_renderValue
(
value_list
)
return
self
.
_renderValue
(
value_list
)
@
profiler_decorator
def
asSQLExpression
(
self
,
column
,
value_list
,
only_group_columns
):
def
asSQLExpression
(
self
,
column
,
value_list
,
only_group_columns
):
"""
"""
This operator can emit a select expression, so it overrides
This operator can emit a select expression, so it overrides
...
...
product/ZSQLCatalog/Operator/OperatorBase.py
View file @
27f4b03d
...
@@ -32,29 +32,23 @@ from zLOG import LOG
...
@@ -32,29 +32,23 @@ from zLOG import LOG
from
Products.ZSQLCatalog.interfaces.operator
import
IOperator
from
Products.ZSQLCatalog.interfaces.operator
import
IOperator
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
zope.interface
import
implements
from
zope.interface
import
implements
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
@
profiler_decorator
def
escapeString
(
value
):
def
escapeString
(
value
):
# Inspired from ERP5Type/Utils:sqlquote, but this product must not depend on it.
# Inspired from ERP5Type/Utils:sqlquote, but this product must not depend on it.
return
"'"
+
value
.
replace
(
'
\
\
'
,
'
\
\
\
\
'
).
replace
(
"'"
,
"''"
)
+
"'"
return
"'"
+
value
.
replace
(
'
\
\
'
,
'
\
\
\
\
'
).
replace
(
"'"
,
"''"
)
+
"'"
@
profiler_decorator
def
valueFloatRenderer
(
value
):
def
valueFloatRenderer
(
value
):
if
isinstance
(
value
,
basestring
):
if
isinstance
(
value
,
basestring
):
value
=
float
(
value
.
replace
(
' '
,
''
))
value
=
float
(
value
.
replace
(
' '
,
''
))
return
repr
(
value
)
return
repr
(
value
)
@
profiler_decorator
def
valueDateTimeRenderer
(
value
):
def
valueDateTimeRenderer
(
value
):
return
'"%s"'
%
(
value
.
toZone
(
'UTC'
).
ISO
(),
)
return
'"%s"'
%
(
value
.
toZone
(
'UTC'
).
ISO
(),
)
@
profiler_decorator
def
valueDefaultRenderer
(
value
):
def
valueDefaultRenderer
(
value
):
LOG
(
'OperatorBase'
,
0
,
'Unhandled value class: %s (%r). Converted to string and escaped.'
%
(
value
.
__class__
.
__name__
,
value
))
LOG
(
'OperatorBase'
,
0
,
'Unhandled value class: %s (%r). Converted to string and escaped.'
%
(
value
.
__class__
.
__name__
,
value
))
return
escapeString
(
str
(
value
))
return
escapeString
(
str
(
value
))
@
profiler_decorator
def
valueNoneRenderer
(
value
):
def
valueNoneRenderer
(
value
):
return
'NULL'
return
'NULL'
...
@@ -70,7 +64,6 @@ value_search_text_renderer = {
...
@@ -70,7 +64,6 @@ value_search_text_renderer = {
'DateTime'
:
str
,
'DateTime'
:
str
,
}
}
@
profiler_decorator
def
valueDefaultSearchTextRenderer
(
value
):
def
valueDefaultSearchTextRenderer
(
value
):
"""
"""
This is just repr, but always surrounding text strings with doublequotes.
This is just repr, but always surrounding text strings with doublequotes.
...
@@ -81,7 +74,6 @@ def valueDefaultSearchTextRenderer(value):
...
@@ -81,7 +74,6 @@ def valueDefaultSearchTextRenderer(value):
result
=
repr
(
value
)
result
=
repr
(
value
)
return
result
return
result
@
profiler_decorator
def
columnFloatRenderer
(
column
,
format
=
None
):
def
columnFloatRenderer
(
column
,
format
=
None
):
"""Format a float column.
"""Format a float column.
...
@@ -98,7 +90,6 @@ def columnFloatRenderer(column, format=None):
...
@@ -98,7 +90,6 @@ def columnFloatRenderer(column, format=None):
column
=
"TRUNCATE(%s, %s)"
%
(
column
,
len
(
format
.
split
(
'.'
)[
-
1
]))
column
=
"TRUNCATE(%s, %s)"
%
(
column
,
len
(
format
.
split
(
'.'
)[
-
1
]))
return
column
return
column
@
profiler_decorator
def
columnDefaultRenderer
(
column
,
format
=
None
):
def
columnDefaultRenderer
(
column
,
format
=
None
):
return
column
return
column
...
@@ -122,7 +113,6 @@ class OperatorBase(object):
...
@@ -122,7 +113,6 @@ class OperatorBase(object):
def
getOperatorSearchText
(
self
):
def
getOperatorSearchText
(
self
):
return
self
.
operator_search_text
return
self
.
operator_search_text
@
profiler_decorator
def
_render
(
self
,
column
,
value
):
def
_render
(
self
,
column
,
value
):
"""
"""
Render given column and value for use in SQL.
Render given column and value for use in SQL.
...
@@ -142,7 +132,6 @@ class OperatorBase(object):
...
@@ -142,7 +132,6 @@ class OperatorBase(object):
value
=
self
.
_renderValue
(
value
)
value
=
self
.
_renderValue
(
value
)
return
column
,
value
return
column
,
value
@
profiler_decorator
def
_renderValue
(
self
,
value
):
def
_renderValue
(
self
,
value
):
"""
"""
Render given value as string.
Render given value as string.
...
@@ -156,7 +145,6 @@ class OperatorBase(object):
...
@@ -156,7 +145,6 @@ class OperatorBase(object):
value
=
value_renderer
.
get
(
value
.
__class__
.
__name__
,
valueDefaultRenderer
)(
value
)
value
=
value_renderer
.
get
(
value
.
__class__
.
__name__
,
valueDefaultRenderer
)(
value
)
return
value
return
value
@
profiler_decorator
def
asSearchText
(
self
,
value
):
def
asSearchText
(
self
,
value
):
return
value_search_text_renderer
.
get
(
value
.
__class__
.
__name__
,
valueDefaultSearchTextRenderer
)(
value
)
return
value_search_text_renderer
.
get
(
value
.
__class__
.
__name__
,
valueDefaultSearchTextRenderer
)(
value
)
...
...
product/ZSQLCatalog/Query/AutoQuery.py
View file @
27f4b03d
...
@@ -32,7 +32,6 @@ from Query import Query
...
@@ -32,7 +32,6 @@ from Query import Query
from
zLOG
import
LOG
from
zLOG
import
LOG
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
class
AutoQuery
(
Query
):
class
AutoQuery
(
Query
):
"""
"""
...
@@ -46,7 +45,6 @@ class AutoQuery(Query):
...
@@ -46,7 +45,6 @@ class AutoQuery(Query):
"""
"""
wrapped_query
=
None
wrapped_query
=
None
@
profiler_decorator
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
*
args
,
**
kw
):
"""
"""
Note: "operator" might contain a logical or a comparison operator.
Note: "operator" might contain a logical or a comparison operator.
...
@@ -64,7 +62,6 @@ class AutoQuery(Query):
...
@@ -64,7 +62,6 @@ class AutoQuery(Query):
raise
ValueError
,
'"key" parameter cannot be used when more than one column is given. key=%r'
%
(
self
.
search_key
,
)
raise
ValueError
,
'"key" parameter cannot be used when more than one column is given. key=%r'
%
(
self
.
search_key
,
)
self
.
search_key
=
kw
.
pop
(
'key'
,
None
)
self
.
search_key
=
kw
.
pop
(
'key'
,
None
)
@
profiler_decorator
def
_createWrappedQuery
(
self
,
sql_catalog
):
def
_createWrappedQuery
(
self
,
sql_catalog
):
"""
"""
Create wrapped query. This requires being able to reach catalog, since
Create wrapped query. This requires being able to reach catalog, since
...
@@ -112,25 +109,21 @@ class AutoQuery(Query):
...
@@ -112,25 +109,21 @@ class AutoQuery(Query):
raise
ValueError
,
'%r failed generating a query from its parameters.'
%
(
self
,
)
raise
ValueError
,
'%r failed generating a query from its parameters.'
%
(
self
,
)
self
.
wrapped_query
=
query
self
.
wrapped_query
=
query
@
profiler_decorator
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
if
self
.
wrapped_query
is
None
:
if
self
.
wrapped_query
is
None
:
self
.
_createWrappedQuery
(
sql_catalog
)
self
.
_createWrappedQuery
(
sql_catalog
)
return
self
.
wrapped_query
.
_asSearchTextExpression
(
sql_catalog
,
column
=
column
)
return
self
.
wrapped_query
.
_asSearchTextExpression
(
sql_catalog
,
column
=
column
)
@
profiler_decorator
def
asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
def
asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
if
self
.
wrapped_query
is
None
:
if
self
.
wrapped_query
is
None
:
self
.
_createWrappedQuery
(
sql_catalog
)
self
.
_createWrappedQuery
(
sql_catalog
)
return
self
.
wrapped_query
.
asSearchTextExpression
(
sql_catalog
,
column
=
column
)
return
self
.
wrapped_query
.
asSearchTextExpression
(
sql_catalog
,
column
=
column
)
@
profiler_decorator
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
if
self
.
wrapped_query
is
None
:
if
self
.
wrapped_query
is
None
:
self
.
_createWrappedQuery
(
sql_catalog
)
self
.
_createWrappedQuery
(
sql_catalog
)
return
self
.
wrapped_query
.
asSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
=
only_group_columns
)
return
self
.
wrapped_query
.
asSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
=
only_group_columns
)
@
profiler_decorator
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
if
self
.
wrapped_query
is
None
:
if
self
.
wrapped_query
is
None
:
self
.
_createWrappedQuery
(
sql_catalog
)
self
.
_createWrappedQuery
(
sql_catalog
)
...
...
product/ZSQLCatalog/Query/ComplexQuery.py
View file @
27f4b03d
...
@@ -33,7 +33,6 @@ from Products.ZSQLCatalog.SQLExpression import SQLExpression
...
@@ -33,7 +33,6 @@ from Products.ZSQLCatalog.SQLExpression import SQLExpression
from
SQLQuery
import
SQLQuery
from
SQLQuery
import
SQLQuery
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
from
Products.ZSQLCatalog.Query.AutoQuery
import
AutoQuery
from
Products.ZSQLCatalog.Query.AutoQuery
import
AutoQuery
from
Products.ZSQLCatalog.Query.RelatedQuery
import
RelatedQuery
from
Products.ZSQLCatalog.Query.RelatedQuery
import
RelatedQuery
...
@@ -46,7 +45,6 @@ class ComplexQuery(Query):
...
@@ -46,7 +45,6 @@ class ComplexQuery(Query):
"""
"""
A ComplexQuery represents logical operations between Query instances.
A ComplexQuery represents logical operations between Query instances.
"""
"""
@
profiler_decorator
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
*
args
,
**
kw
):
"""
"""
*args (tuple of Query or of list of Query)
*args (tuple of Query or of list of Query)
...
@@ -142,7 +140,6 @@ class ComplexQuery(Query):
...
@@ -142,7 +140,6 @@ class ComplexQuery(Query):
self
.
logical_operator
==
'or'
):
self
.
logical_operator
==
'or'
):
raise
NotImplementedError
raise
NotImplementedError
@
profiler_decorator
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
if
column
in
(
None
,
''
):
if
column
in
(
None
,
''
):
query_column
=
column
query_column
=
column
...
@@ -186,7 +183,6 @@ class ComplexQuery(Query):
...
@@ -186,7 +183,6 @@ class ComplexQuery(Query):
result
=
'%s:%s'
%
(
column
,
result
)
result
=
'%s:%s'
%
(
column
,
result
)
return
self_is_composed
,
result
return
self_is_composed
,
result
@
profiler_decorator
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
sql_expression_list
=
[
x
.
asSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
)
sql_expression_list
=
[
x
.
asSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
)
for
x
in
self
.
query_list
]
for
x
in
self
.
query_list
]
...
@@ -197,7 +193,6 @@ class ComplexQuery(Query):
...
@@ -197,7 +193,6 @@ class ComplexQuery(Query):
where_expression_operator
=
self
.
logical_operator
,
where_expression_operator
=
self
.
logical_operator
,
from_expression
=
self
.
from_expression
)
from_expression
=
self
.
from_expression
)
@
profiler_decorator
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
for
query
in
self
.
query_list
:
for
query
in
self
.
query_list
:
query
.
registerColumnMap
(
sql_catalog
,
column_map
)
query
.
registerColumnMap
(
sql_catalog
,
column_map
)
...
@@ -205,7 +200,6 @@ class ComplexQuery(Query):
...
@@ -205,7 +200,6 @@ class ComplexQuery(Query):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<%s of %r.join(%r)>'
%
(
self
.
__class__
.
__name__
,
self
.
logical_operator
,
self
.
query_list
)
return
'<%s of %r.join(%r)>'
%
(
self
.
__class__
.
__name__
,
self
.
logical_operator
,
self
.
query_list
)
@
profiler_decorator
def
setTableAliasList
(
self
,
table_alias_list
):
def
setTableAliasList
(
self
,
table_alias_list
):
"""
"""
This function is here for backward compatibility.
This function is here for backward compatibility.
...
@@ -217,7 +211,6 @@ class ComplexQuery(Query):
...
@@ -217,7 +211,6 @@ class ComplexQuery(Query):
assert
len
(
self
.
query_list
)
==
1
assert
len
(
self
.
query_list
)
==
1
self
.
query_list
[
0
].
setTableAliasList
(
table_alias_list
)
self
.
query_list
[
0
].
setTableAliasList
(
table_alias_list
)
@
profiler_decorator
def
setGroup
(
self
,
group
):
def
setGroup
(
self
,
group
):
for
query
in
self
.
query_list
:
for
query
in
self
.
query_list
:
query
.
setGroup
(
group
)
query
.
setGroup
(
group
)
...
...
product/ZSQLCatalog/Query/EntireQuery.py
View file @
27f4b03d
...
@@ -35,7 +35,6 @@ from zLOG import LOG
...
@@ -35,7 +35,6 @@ from zLOG import LOG
from
Products.ZSQLCatalog.interfaces.entire_query
import
IEntireQuery
from
Products.ZSQLCatalog.interfaces.entire_query
import
IEntireQuery
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
zope.interface
import
implements
from
zope.interface
import
implements
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
from
Products.ZSQLCatalog.TableDefinition
import
LegacyTableDefinition
from
Products.ZSQLCatalog.TableDefinition
import
LegacyTableDefinition
def
defaultDict
(
value
):
def
defaultDict
(
value
):
...
@@ -55,7 +54,6 @@ class EntireQuery(object):
...
@@ -55,7 +54,6 @@ class EntireQuery(object):
column_map
=
None
column_map
=
None
@
profiler_decorator
def
__init__
(
self
,
query
,
def
__init__
(
self
,
query
,
order_by_list
=
(),
order_by_list
=
(),
group_by_list
=
(),
group_by_list
=
(),
...
@@ -82,7 +80,6 @@ class EntireQuery(object):
...
@@ -82,7 +80,6 @@ class EntireQuery(object):
def
asSearchTextExpression
(
self
,
sql_catalog
):
def
asSearchTextExpression
(
self
,
sql_catalog
):
return
self
.
query
.
asSearchTextExpression
(
sql_catalog
)
return
self
.
query
.
asSearchTextExpression
(
sql_catalog
)
@
profiler_decorator
def
asSQLExpression
(
self
,
sql_catalog
,
only_group_columns
):
def
asSQLExpression
(
self
,
sql_catalog
,
only_group_columns
):
column_map
=
self
.
column_map
column_map
=
self
.
column_map
if
column_map
is
None
:
if
column_map
is
None
:
...
...
product/ZSQLCatalog/Query/RelatedQuery.py
View file @
27f4b03d
...
@@ -32,13 +32,11 @@ from Query import Query
...
@@ -32,13 +32,11 @@ from Query import Query
from
Products.ZSQLCatalog.SQLExpression
import
SQLExpression
from
Products.ZSQLCatalog.SQLExpression
import
SQLExpression
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
class
RelatedQuery
(
Query
):
class
RelatedQuery
(
Query
):
"""
"""
A RelatedQuery represents the is a container for a join condition.
A RelatedQuery represents the is a container for a join condition.
"""
"""
@
profiler_decorator
def
__init__
(
self
,
search_key
,
join_condition
=
None
,
table_alias_list
=
None
):
def
__init__
(
self
,
search_key
,
join_condition
=
None
,
table_alias_list
=
None
):
"""
"""
search_key (SearchKey)
search_key (SearchKey)
...
@@ -53,7 +51,6 @@ class RelatedQuery(Query):
...
@@ -53,7 +51,6 @@ class RelatedQuery(Query):
self
.
join_condition
=
join_condition
self
.
join_condition
=
join_condition
self
.
table_alias_list
=
table_alias_list
self
.
table_alias_list
=
table_alias_list
@
profiler_decorator
def
setTableAliasList
(
self
,
table_alias_list
):
def
setTableAliasList
(
self
,
table_alias_list
):
"""
"""
This function is here for backward compatibility.
This function is here for backward compatibility.
...
@@ -64,7 +61,6 @@ class RelatedQuery(Query):
...
@@ -64,7 +61,6 @@ class RelatedQuery(Query):
"""
"""
self
.
table_alias_list
=
table_alias_list
self
.
table_alias_list
=
table_alias_list
@
profiler_decorator
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
assert
column
is
None
assert
column
is
None
join_condition
=
self
.
join_condition
join_condition
=
self
.
join_condition
...
@@ -74,7 +70,6 @@ class RelatedQuery(Query):
...
@@ -74,7 +70,6 @@ class RelatedQuery(Query):
result
=
join_condition
.
asSearchTextExpression
(
sql_catalog
,
column
=
self
.
search_key
.
getColumn
())
result
=
join_condition
.
asSearchTextExpression
(
sql_catalog
,
column
=
self
.
search_key
.
getColumn
())
return
False
,
result
return
False
,
result
@
profiler_decorator
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
sql_expression_list
=
[
self
.
search_key
.
buildSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
,
self
.
group
)]
sql_expression_list
=
[
self
.
search_key
.
buildSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
,
self
.
group
)]
join_condition
=
self
.
join_condition
join_condition
=
self
.
join_condition
...
@@ -82,7 +77,6 @@ class RelatedQuery(Query):
...
@@ -82,7 +77,6 @@ class RelatedQuery(Query):
sql_expression_list
.
append
(
join_condition
.
asSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
))
sql_expression_list
.
append
(
join_condition
.
asSQLExpression
(
sql_catalog
,
column_map
,
only_group_columns
))
return
SQLExpression
(
self
,
sql_expression_list
=
sql_expression_list
,
where_expression_operator
=
'and'
)
return
SQLExpression
(
self
,
sql_expression_list
=
sql_expression_list
,
where_expression_operator
=
'and'
)
@
profiler_decorator
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
self
.
group
=
self
.
search_key
.
registerColumnMap
(
column_map
,
table_alias_list
=
self
.
table_alias_list
)
self
.
group
=
self
.
search_key
.
registerColumnMap
(
column_map
,
table_alias_list
=
self
.
table_alias_list
)
join_condition
=
self
.
join_condition
join_condition
=
self
.
join_condition
...
...
product/ZSQLCatalog/Query/SimpleQuery.py
View file @
27f4b03d
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
from
Query
import
Query
from
Query
import
Query
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
Products.ZSQLCatalog.interfaces.query
import
IQuery
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
,
list_type_list
from
Products.ZSQLCatalog.SQLCatalog
import
list_type_list
from
zLOG
import
LOG
,
WARNING
from
zLOG
import
LOG
,
WARNING
NULL_SEARCH_TEXT_OPERATOR_DICT
=
{
NULL_SEARCH_TEXT_OPERATOR_DICT
=
{
...
@@ -46,7 +46,6 @@ class SimpleQuery(Query):
...
@@ -46,7 +46,6 @@ class SimpleQuery(Query):
A SimpleQuery represents a single comparison between a single column and
A SimpleQuery represents a single comparison between a single column and
one or more values.
one or more values.
"""
"""
@
profiler_decorator
def
__init__
(
self
,
search_key
=
None
,
comparison_operator
=
'='
,
group
=
None
,
**
kw
):
def
__init__
(
self
,
search_key
=
None
,
comparison_operator
=
'='
,
group
=
None
,
**
kw
):
"""
"""
search_key (None, SearchKey instance)
search_key (None, SearchKey instance)
...
@@ -103,17 +102,14 @@ class SimpleQuery(Query):
...
@@ -103,17 +102,14 @@ class SimpleQuery(Query):
self
.
comparison_operator
=
comparison_operator
self
.
comparison_operator
=
comparison_operator
self
.
group
=
group
self
.
group
=
group
@
profiler_decorator
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
def
_asSearchTextExpression
(
self
,
sql_catalog
,
column
=
None
):
return
False
,
self
.
getSearchKey
(
sql_catalog
).
buildSearchTextExpression
(
self
.
getOperator
(
sql_catalog
),
self
.
getValue
(),
column
=
column
)
return
False
,
self
.
getSearchKey
(
sql_catalog
).
buildSearchTextExpression
(
self
.
getOperator
(
sql_catalog
),
self
.
getValue
(),
column
=
column
)
@
profiler_decorator
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
def
asSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
):
return
self
.
getSearchKey
(
sql_catalog
).
buildSQLExpression
(
return
self
.
getSearchKey
(
sql_catalog
).
buildSQLExpression
(
self
.
getOperator
(
sql_catalog
),
self
.
getValue
(),
self
.
getOperator
(
sql_catalog
),
self
.
getValue
(),
column_map
,
only_group_columns
,
group
=
self
.
group
)
column_map
,
only_group_columns
,
group
=
self
.
group
)
@
profiler_decorator
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
def
registerColumnMap
(
self
,
sql_catalog
,
column_map
):
self
.
group
=
self
.
getSearchKey
(
sql_catalog
).
registerColumnMap
(
column_map
,
group
=
self
.
group
,
simple_query
=
self
)
self
.
group
=
self
.
getSearchKey
(
sql_catalog
).
registerColumnMap
(
column_map
,
group
=
self
.
group
,
simple_query
=
self
)
...
...
product/ZSQLCatalog/SQLCatalog.py
View file @
27f4b03d
...
@@ -59,14 +59,6 @@ try:
...
@@ -59,14 +59,6 @@ try:
except
ImportError
:
except
ImportError
:
ActiveObject
=
ExtensionClass
.
Base
ActiveObject
=
ExtensionClass
.
Base
PROFILING_ENABLED
=
False
if
PROFILING_ENABLED
:
from
tiny_profiler
import
profiler_decorator
,
profiler_report
,
profiler_reset
else
:
def
profiler_decorator
(
func
):
return
func
try
:
try
:
from
Products.CMFCore.Expression
import
Expression
from
Products.CMFCore.Expression
import
Expression
from
Products.PageTemplates.Expressions
import
getEngine
from
Products.PageTemplates.Expressions
import
getEngine
...
@@ -1108,14 +1100,11 @@ class Catalog(Folder,
...
@@ -1108,14 +1100,11 @@ class Catalog(Folder,
"""
"""
return
self
.
_getColumnIds
()[:]
return
self
.
_getColumnIds
()[:]
@
profiler_decorator
@
transactional_cache_decorator
(
'SQLCatalog.getColumnMap'
)
@
transactional_cache_decorator
(
'SQLCatalog.getColumnMap'
)
@
profiler_decorator
@
caching_instance_method
(
id
=
'SQLCatalog.getColumnMap'
,
@
caching_instance_method
(
id
=
'SQLCatalog.getColumnMap'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
cache_id_generator
=
generateCatalogCacheId
,
cache_id_generator
=
generateCatalogCacheId
,
)
)
@
profiler_decorator
def
getColumnMap
(
self
):
def
getColumnMap
(
self
):
"""
"""
Calls the show column method and returns dictionnary of
Calls the show column method and returns dictionnary of
...
@@ -1128,14 +1117,11 @@ class Catalog(Folder,
...
@@ -1128,14 +1117,11 @@ class Catalog(Folder,
result
.
setdefault
(
'%s.%s'
%
(
table
,
field
),
[]).
append
(
table
)
# Is this inconsistent ?
result
.
setdefault
(
'%s.%s'
%
(
table
,
field
),
[]).
append
(
table
)
# Is this inconsistent ?
return
result
return
result
@
profiler_decorator
@
transactional_cache_decorator
(
'SQLCatalog.getResultColumnIds'
)
@
transactional_cache_decorator
(
'SQLCatalog.getResultColumnIds'
)
@
profiler_decorator
@
caching_instance_method
(
id
=
'SQLCatalog.getResultColumnIds'
,
@
caching_instance_method
(
id
=
'SQLCatalog.getResultColumnIds'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
cache_id_generator
=
generateCatalogCacheId
,
cache_id_generator
=
generateCatalogCacheId
,
)
)
@
profiler_decorator
def
getResultColumnIds
(
self
):
def
getResultColumnIds
(
self
):
"""
"""
Calls the show column method and returns dictionnary of
Calls the show column method and returns dictionnary of
...
@@ -1150,14 +1136,11 @@ class Catalog(Folder,
...
@@ -1150,14 +1136,11 @@ class Catalog(Folder,
keys
.
sort
()
keys
.
sort
()
return
keys
return
keys
@
profiler_decorator
@
transactional_cache_decorator
(
'SQLCatalog.getSortColumnIds'
)
@
transactional_cache_decorator
(
'SQLCatalog.getSortColumnIds'
)
@
profiler_decorator
@
caching_instance_method
(
id
=
'SQLCatalog.getSortColumnIds'
,
@
caching_instance_method
(
id
=
'SQLCatalog.getSortColumnIds'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
cache_id_generator
=
generateCatalogCacheId
,
cache_id_generator
=
generateCatalogCacheId
,
)
)
@
profiler_decorator
def
getSortColumnIds
(
self
):
def
getSortColumnIds
(
self
):
"""
"""
Calls the show column method and returns dictionnary of
Calls the show column method and returns dictionnary of
...
@@ -1940,9 +1923,7 @@ class Catalog(Folder,
...
@@ -1940,9 +1923,7 @@ class Catalog(Folder,
"""
"""
return
self
.
getCatalogMethodIds
(
valid_method_meta_type_list
=
(
'Script (Python)'
,
))
return
self
.
getCatalogMethodIds
(
valid_method_meta_type_list
=
(
'Script (Python)'
,
))
@
profiler_decorator
@
transactional_cache_decorator
(
'SQLCatalog._getSQLCatalogRelatedKeyList'
)
@
transactional_cache_decorator
(
'SQLCatalog._getSQLCatalogRelatedKeyList'
)
@
profiler_decorator
def
_getSQLCatalogRelatedKeySet
(
self
):
def
_getSQLCatalogRelatedKeySet
(
self
):
column_map
=
self
.
getColumnMap
()
column_map
=
self
.
getColumnMap
()
column_set
=
set
(
column_map
)
column_set
=
set
(
column_map
)
...
@@ -2008,7 +1989,6 @@ class Catalog(Folder,
...
@@ -2008,7 +1989,6 @@ class Catalog(Folder,
"""
"""
return
self
.
_getTableIndex
(
table
).
copy
()
return
self
.
_getTableIndex
(
table
).
copy
()
@
profiler_decorator
def
isValidColumn
(
self
,
column_id
):
def
isValidColumn
(
self
,
column_id
):
"""
"""
Tells wether given name is or not an existing column.
Tells wether given name is or not an existing column.
...
@@ -2023,7 +2003,6 @@ class Catalog(Folder,
...
@@ -2023,7 +2003,6 @@ class Catalog(Folder,
result
=
self
.
getRelatedKeyDefinition
(
column_id
)
is
not
None
result
=
self
.
getRelatedKeyDefinition
(
column_id
)
is
not
None
return
result
return
result
@
profiler_decorator
def
getRelatedKeyDefinition
(
self
,
key
):
def
getRelatedKeyDefinition
(
self
,
key
):
"""
"""
Returns the definition of given related key name if found, None
Returns the definition of given related key name if found, None
...
@@ -2067,7 +2046,6 @@ class Catalog(Folder,
...
@@ -2067,7 +2046,6 @@ class Catalog(Folder,
def
getScriptableKeyScript
(
self
,
key
):
def
getScriptableKeyScript
(
self
,
key
):
return
self
.
_getgetScriptableKeyDict
().
get
(
key
)
return
self
.
_getgetScriptableKeyDict
().
get
(
key
)
@
profiler_decorator
def
getColumnSearchKey
(
self
,
key
,
search_key_name
=
None
):
def
getColumnSearchKey
(
self
,
key
,
search_key_name
=
None
):
"""
"""
Return a SearchKey instance for given key, using search_key_name
Return a SearchKey instance for given key, using search_key_name
...
@@ -2096,7 +2074,6 @@ class Catalog(Folder,
...
@@ -2096,7 +2074,6 @@ class Catalog(Folder,
def
hasColumn
(
self
,
column
):
def
hasColumn
(
self
,
column
):
return
self
.
getColumnSearchKey
(
column
)[
0
]
is
not
None
return
self
.
getColumnSearchKey
(
column
)[
0
]
is
not
None
@
profiler_decorator
def
getColumnDefaultSearchKey
(
self
,
key
,
search_key_name
=
None
):
def
getColumnDefaultSearchKey
(
self
,
key
,
search_key_name
=
None
):
"""
"""
Return a SearchKey instance which would ultimately receive the value
Return a SearchKey instance which would ultimately receive the value
...
@@ -2112,7 +2089,6 @@ class Catalog(Folder,
...
@@ -2112,7 +2089,6 @@ class Catalog(Folder,
related_key_definition
=
related_key_definition
)
related_key_definition
=
related_key_definition
)
return
search_key
return
search_key
@
profiler_decorator
def
buildSingleQuery
(
self
,
key
,
value
,
search_key_name
=
None
,
logical_operator
=
None
,
comparison_operator
=
None
):
def
buildSingleQuery
(
self
,
key
,
value
,
search_key_name
=
None
,
logical_operator
=
None
,
comparison_operator
=
None
):
"""
"""
From key and value, determine the SearchKey to use and generate a Query
From key and value, determine the SearchKey to use and generate a Query
...
@@ -2140,7 +2116,6 @@ class Catalog(Folder,
...
@@ -2140,7 +2116,6 @@ class Catalog(Folder,
result
=
script
(
value
)
result
=
script
(
value
)
return
result
return
result
@
profiler_decorator
def
_buildQueryFromAbstractSyntaxTreeNode
(
self
,
node
,
search_key
,
wrap
):
def
_buildQueryFromAbstractSyntaxTreeNode
(
self
,
node
,
search_key
,
wrap
):
if
search_key
.
dequoteParsedText
():
if
search_key
.
dequoteParsedText
():
_dequote
=
dequote
_dequote
=
dequote
...
@@ -2178,7 +2153,6 @@ class Catalog(Folder,
...
@@ -2178,7 +2153,6 @@ class Catalog(Folder,
result
=
None
result
=
None
return
result
return
result
@
profiler_decorator
def
buildQueryFromAbstractSyntaxTreeNode
(
self
,
node
,
key
,
wrap
=
lambda
x
:
x
):
def
buildQueryFromAbstractSyntaxTreeNode
(
self
,
node
,
key
,
wrap
=
lambda
x
:
x
):
"""
"""
Build a query from given Abstract Syntax Tree (AST) node by recursing in
Build a query from given Abstract Syntax Tree (AST) node by recursing in
...
@@ -2229,7 +2203,6 @@ class Catalog(Folder,
...
@@ -2229,7 +2203,6 @@ class Catalog(Folder,
return
self
.
_parseSearchText
(
self
.
getSearchKey
(
return
self
.
_parseSearchText
(
self
.
getSearchKey
(
column
,
search_key
=
search_key
),
search_text
,
is_valid
=
is_valid
)
column
,
search_key
=
search_key
),
search_text
,
is_valid
=
is_valid
)
@
profiler_decorator
def
buildQuery
(
self
,
kw
,
ignore_empty_string
=
True
,
operator
=
'and'
):
def
buildQuery
(
self
,
kw
,
ignore_empty_string
=
True
,
operator
=
'and'
):
query_list
=
[]
query_list
=
[]
append
=
query_list
.
append
append
=
query_list
.
append
...
@@ -2317,7 +2290,6 @@ class Catalog(Folder,
...
@@ -2317,7 +2290,6 @@ class Catalog(Folder,
return
ComplexQuery
(
query_list
,
logical_operator
=
operator
,
return
ComplexQuery
(
query_list
,
logical_operator
=
operator
,
unknown_column_dict
=
unknown_column_dict
)
unknown_column_dict
=
unknown_column_dict
)
@
profiler_decorator
def
buildOrderByList
(
self
,
sort_on
=
None
,
sort_order
=
None
,
order_by_expression
=
None
):
def
buildOrderByList
(
self
,
sort_on
=
None
,
sort_order
=
None
,
order_by_expression
=
None
):
"""
"""
Internal method. Should not be used by code outside buildSQLQuery.
Internal method. Should not be used by code outside buildSQLQuery.
...
@@ -2361,7 +2333,6 @@ class Catalog(Folder,
...
@@ -2361,7 +2333,6 @@ class Catalog(Folder,
order_by_list
=
[[
x
.
strip
()]
for
x
in
order_by_expression
.
split
(
','
)]
order_by_list
=
[[
x
.
strip
()]
for
x
in
order_by_expression
.
split
(
','
)]
return
order_by_list
return
order_by_list
@
profiler_decorator
def
buildEntireQuery
(
self
,
kw
,
query_table
=
'catalog'
,
ignore_empty_string
=
1
,
def
buildEntireQuery
(
self
,
kw
,
query_table
=
'catalog'
,
ignore_empty_string
=
1
,
limit
=
None
,
extra_column_list
=
()):
limit
=
None
,
extra_column_list
=
()):
group_by_list
=
kw
.
pop
(
'group_by_list'
,
kw
.
pop
(
'group_by'
,
kw
.
pop
(
'group_by_expression'
,
())))
group_by_list
=
kw
.
pop
(
'group_by_list'
,
kw
.
pop
(
'group_by'
,
kw
.
pop
(
'group_by_expression'
,
())))
...
@@ -2433,7 +2404,6 @@ class Catalog(Folder,
...
@@ -2433,7 +2404,6 @@ class Catalog(Folder,
extra_column_list
=
extra_column_list
,
extra_column_list
=
extra_column_list
,
from_expression
=
from_expression
)
from_expression
=
from_expression
)
@
profiler_decorator
def
buildSQLQuery
(
self
,
query_table
=
'catalog'
,
REQUEST
=
None
,
def
buildSQLQuery
(
self
,
query_table
=
'catalog'
,
REQUEST
=
None
,
ignore_empty_string
=
1
,
only_group_columns
=
False
,
ignore_empty_string
=
1
,
only_group_columns
=
False
,
limit
=
None
,
extra_column_list
=
(),
limit
=
None
,
extra_column_list
=
(),
...
@@ -2447,14 +2417,11 @@ class Catalog(Folder,
...
@@ -2447,14 +2417,11 @@ class Catalog(Folder,
# Compatibililty SQL Sql
# Compatibililty SQL Sql
buildSqlQuery
=
buildSQLQuery
buildSqlQuery
=
buildSQLQuery
@
profiler_decorator
@
transactional_cache_decorator
(
'SQLCatalog._getSearchKeyDict'
)
@
transactional_cache_decorator
(
'SQLCatalog._getSearchKeyDict'
)
@
profiler_decorator
@
caching_instance_method
(
id
=
'SQLCatalog._getSearchKeyDict'
,
@
caching_instance_method
(
id
=
'SQLCatalog._getSearchKeyDict'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
cache_id_generator
=
generateCatalogCacheId
,
cache_id_generator
=
generateCatalogCacheId
,
)
)
@
profiler_decorator
def
_getSearchKeyDict
(
self
):
def
_getSearchKeyDict
(
self
):
result
=
{}
result
=
{}
search_key_column_dict
=
{
search_key_column_dict
=
{
...
@@ -2476,7 +2443,6 @@ class Catalog(Folder,
...
@@ -2476,7 +2443,6 @@ class Catalog(Folder,
LOG
(
'SQLCatalog'
,
WARNING
,
'Wrong configuration for sql_catalog_search_keys: %r'
%
line
)
LOG
(
'SQLCatalog'
,
WARNING
,
'Wrong configuration for sql_catalog_search_keys: %r'
%
line
)
return
result
return
result
@
profiler_decorator
def
getSearchKey
(
self
,
column
,
search_key
=
None
):
def
getSearchKey
(
self
,
column
,
search_key
=
None
):
"""
"""
Return an instance of a SearchKey class.
Return an instance of a SearchKey class.
...
@@ -2508,7 +2474,6 @@ class Catalog(Folder,
...
@@ -2508,7 +2474,6 @@ class Catalog(Folder,
# the ZSQLMethod class itself
# the ZSQLMethod class itself
'zsql_brain'
,
'zsql_brain'
,
])
])
@
profiler_decorator
def
_queryResults
(
self
,
REQUEST
=
None
,
build_sql_query_method
=
None
,
**
kw
):
def
_queryResults
(
self
,
REQUEST
=
None
,
build_sql_query_method
=
None
,
**
kw
):
""" Returns a list of brains from a set of constraints on variables """
""" Returns a list of brains from a set of constraints on variables """
if
build_sql_query_method
is
None
:
if
build_sql_query_method
is
None
:
...
@@ -2823,7 +2788,6 @@ import SearchKey
...
@@ -2823,7 +2788,6 @@ import SearchKey
SEARCH_KEY_INSTANCE_POOL
=
{}
SEARCH_KEY_INSTANCE_POOL
=
{}
SEARCH_KEY_CLASS_CACHE
=
{}
SEARCH_KEY_CLASS_CACHE
=
{}
@
profiler_decorator
def
getSearchKeyInstance
(
search_key_class_name
,
column
):
def
getSearchKeyInstance
(
search_key_class_name
,
column
):
assert
isinstance
(
search_key_class_name
,
basestring
)
assert
isinstance
(
search_key_class_name
,
basestring
)
try
:
try
:
...
@@ -2877,14 +2841,3 @@ from Query.EntireQuery import EntireQuery
...
@@ -2877,14 +2841,3 @@ from Query.EntireQuery import EntireQuery
from
Query.SQLQuery
import
SQLQuery
from
Query.SQLQuery
import
SQLQuery
verifyClass
(
ISearchKeyCatalog
,
Catalog
)
verifyClass
(
ISearchKeyCatalog
,
Catalog
)
if
PROFILING_ENABLED
:
def
Catalog_dumpProfilerData
(
self
):
return
profiler_report
()
def
Catalog_resetProfilerData
(
self
):
profiler_reset
()
Catalog
.
dumpProfilerData
=
Catalog_dumpProfilerData
Catalog
.
resetProfilerData
=
Catalog_resetProfilerData
product/ZSQLCatalog/SQLExpression.py
View file @
27f4b03d
...
@@ -32,7 +32,6 @@ from interfaces.sql_expression import ISQLExpression
...
@@ -32,7 +32,6 @@ from interfaces.sql_expression import ISQLExpression
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
zope.interface
import
implements
from
zope.interface
import
implements
from
types
import
NoneType
from
types
import
NoneType
from
SQLCatalog
import
profiler_decorator
SQL_LIST_SEPARATOR
=
', '
SQL_LIST_SEPARATOR
=
', '
SQL_TABLE_FORMAT
=
'%s'
# XXX: should be changed to '`%s`', but this breaks some ZSQLMethods.
SQL_TABLE_FORMAT
=
'%s'
# XXX: should be changed to '`%s`', but this breaks some ZSQLMethods.
...
@@ -85,7 +84,6 @@ class SQLExpression(object):
...
@@ -85,7 +84,6 @@ class SQLExpression(object):
implements
(
ISQLExpression
)
implements
(
ISQLExpression
)
@
profiler_decorator
def
__init__
(
self
,
def
__init__
(
self
,
query
,
query
,
table_alias_dict
=
None
,
table_alias_dict
=
None
,
...
@@ -136,7 +134,6 @@ class SQLExpression(object):
...
@@ -136,7 +134,6 @@ class SQLExpression(object):
DeprecationWarning
)
DeprecationWarning
)
self
.
from_expression
=
from_expression
self
.
from_expression
=
from_expression
@
profiler_decorator
def
getTableAliasDict
(
self
):
def
getTableAliasDict
(
self
):
"""
"""
Returns a dictionary:
Returns a dictionary:
...
@@ -163,7 +160,6 @@ class SQLExpression(object):
...
@@ -163,7 +160,6 @@ class SQLExpression(object):
result
[
alias
]
=
table_name
result
[
alias
]
=
table_name
return
result
return
result
@
profiler_decorator
def
getFromExpression
(
self
):
def
getFromExpression
(
self
):
"""
"""
Returns a TableDefinition stored in one of the from_expressions or None
Returns a TableDefinition stored in one of the from_expressions or None
...
@@ -186,7 +182,6 @@ class SQLExpression(object):
...
@@ -186,7 +182,6 @@ class SQLExpression(object):
raise
ValueError
,
message
raise
ValueError
,
message
return
result
return
result
@
profiler_decorator
def
getOrderByList
(
self
):
def
getOrderByList
(
self
):
"""
"""
Returns a list of strings.
Returns a list of strings.
...
@@ -206,7 +201,6 @@ class SQLExpression(object):
...
@@ -206,7 +201,6 @@ class SQLExpression(object):
known_column_set
.
add
(
order_by
[
0
])
known_column_set
.
add
(
order_by
[
0
])
return
result
return
result
@
profiler_decorator
def
_getOrderByDict
(
self
,
delay_error
=
True
):
def
_getOrderByDict
(
self
,
delay_error
=
True
):
result_dict
=
self
.
order_by_dict
.
copy
()
result_dict
=
self
.
order_by_dict
.
copy
()
for
sql_expression
in
self
.
sql_expression_list
:
for
sql_expression
in
self
.
sql_expression_list
:
...
@@ -232,7 +226,6 @@ class SQLExpression(object):
...
@@ -232,7 +226,6 @@ class SQLExpression(object):
def
getOrderByDict
(
self
):
def
getOrderByDict
(
self
):
return
self
.
_getOrderByDict
(
delay_error
=
False
)
return
self
.
_getOrderByDict
(
delay_error
=
False
)
@
profiler_decorator
def
getOrderByExpression
(
self
):
def
getOrderByExpression
(
self
):
"""
"""
Returns a string.
Returns a string.
...
@@ -251,7 +244,6 @@ class SQLExpression(object):
...
@@ -251,7 +244,6 @@ class SQLExpression(object):
append
(
expression
)
append
(
expression
)
return
SQL_LIST_SEPARATOR
.
join
(
result
)
return
SQL_LIST_SEPARATOR
.
join
(
result
)
@
profiler_decorator
def
getWhereExpression
(
self
):
def
getWhereExpression
(
self
):
"""
"""
Returns a string.
Returns a string.
...
@@ -273,7 +265,6 @@ class SQLExpression(object):
...
@@ -273,7 +265,6 @@ class SQLExpression(object):
result
=
'(%s)'
%
(
operator
.
join
(
x
.
getWhereExpression
()
for
x
in
self
.
sql_expression_list
),
)
result
=
'(%s)'
%
(
operator
.
join
(
x
.
getWhereExpression
()
for
x
in
self
.
sql_expression_list
),
)
return
result
return
result
@
profiler_decorator
def
getLimit
(
self
):
def
getLimit
(
self
):
"""
"""
Returns a list of 1 or 2 items (int or string).
Returns a list of 1 or 2 items (int or string).
...
@@ -296,7 +287,6 @@ class SQLExpression(object):
...
@@ -296,7 +287,6 @@ class SQLExpression(object):
raise
ValueError
,
message
raise
ValueError
,
message
return
result
return
result
@
profiler_decorator
def
getLimitExpression
(
self
):
def
getLimitExpression
(
self
):
"""
"""
Returns a string.
Returns a string.
...
@@ -305,7 +295,6 @@ class SQLExpression(object):
...
@@ -305,7 +295,6 @@ class SQLExpression(object):
"""
"""
return
SQL_LIST_SEPARATOR
.
join
(
str
(
x
)
for
x
in
self
.
getLimit
())
return
SQL_LIST_SEPARATOR
.
join
(
str
(
x
)
for
x
in
self
.
getLimit
())
@
profiler_decorator
def
getGroupByset
(
self
):
def
getGroupByset
(
self
):
"""
"""
Returns a set of strings.
Returns a set of strings.
...
@@ -318,7 +307,6 @@ class SQLExpression(object):
...
@@ -318,7 +307,6 @@ class SQLExpression(object):
result
.
update
(
sql_expression
.
getGroupByset
())
result
.
update
(
sql_expression
.
getGroupByset
())
return
result
return
result
@
profiler_decorator
def
getGroupByExpression
(
self
):
def
getGroupByExpression
(
self
):
"""
"""
Returns a string.
Returns a string.
...
@@ -330,7 +318,6 @@ class SQLExpression(object):
...
@@ -330,7 +318,6 @@ class SQLExpression(object):
def
canMergeSelectDict
(
self
):
def
canMergeSelectDict
(
self
):
return
self
.
can_merge_select_dict
return
self
.
can_merge_select_dict
@
profiler_decorator
def
_getSelectDict
(
self
):
def
_getSelectDict
(
self
):
result
=
self
.
select_dict
.
copy
()
result
=
self
.
select_dict
.
copy
()
mergeable_set
=
set
()
mergeable_set
=
set
()
...
@@ -361,7 +348,6 @@ class SQLExpression(object):
...
@@ -361,7 +348,6 @@ class SQLExpression(object):
mergeable_set
.
add
(
alias
)
mergeable_set
.
add
(
alias
)
return
result
,
mergeable_set
return
result
,
mergeable_set
@
profiler_decorator
def
getSelectDict
(
self
):
def
getSelectDict
(
self
):
"""
"""
Returns a dict:
Returns a dict:
...
@@ -374,7 +360,6 @@ class SQLExpression(object):
...
@@ -374,7 +360,6 @@ class SQLExpression(object):
"""
"""
return
self
.
_getSelectDict
()[
0
]
return
self
.
_getSelectDict
()[
0
]
@
profiler_decorator
def
getSelectExpression
(
self
):
def
getSelectExpression
(
self
):
"""
"""
Returns a string.
Returns a string.
...
@@ -395,7 +380,6 @@ class SQLExpression(object):
...
@@ -395,7 +380,6 @@ class SQLExpression(object):
append
((
SQL_TABLE_FORMAT
%
(
alias
,
),
SQL_TABLE_FORMAT
%
(
table
,
)))
append
((
SQL_TABLE_FORMAT
%
(
alias
,
),
SQL_TABLE_FORMAT
%
(
table
,
)))
return
from_table_list
return
from_table_list
@
profiler_decorator
def
asSQLExpressionDict
(
self
):
def
asSQLExpressionDict
(
self
):
from_expression
=
self
.
getFromExpression
()
from_expression
=
self
.
getFromExpression
()
from_table_list
=
self
.
getFromTableList
()
from_table_list
=
self
.
getFromTableList
()
...
...
product/ZSQLCatalog/SearchKey/DateTimeKey.py
View file @
27f4b03d
...
@@ -36,7 +36,6 @@ from zLOG import LOG
...
@@ -36,7 +36,6 @@ from zLOG import LOG
from
DateTime.DateTime
import
DateTime
,
DateTimeError
,
_cache
from
DateTime.DateTime
import
DateTime
,
DateTimeError
,
_cache
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
from
Products.ZSQLCatalog.SearchText
import
parse
from
Products.ZSQLCatalog.SearchText
import
parse
MARKER
=
[]
MARKER
=
[]
...
@@ -48,11 +47,9 @@ date_completion_format_dict = {
...
@@ -48,11 +47,9 @@ date_completion_format_dict = {
'international'
:
[
'%s/01/01'
,
'%s/01'
]
'international'
:
[
'%s/01/01'
,
'%s/01'
]
}
}
@
profiler_decorator
def
_DateTime
(
*
args
,
**
kw
):
def
_DateTime
(
*
args
,
**
kw
):
return
DateTime
(
*
args
,
**
kw
)
return
DateTime
(
*
args
,
**
kw
)
@
profiler_decorator
def
castDate
(
value
,
change_timezone
=
True
):
def
castDate
(
value
,
change_timezone
=
True
):
if
value
is
None
:
if
value
is
None
:
return
None
return
None
...
@@ -114,7 +111,6 @@ def getYearLen(datetime):
...
@@ -114,7 +111,6 @@ def getYearLen(datetime):
delta_list
=
[
getYearLen
,
getMonthLen
,
1
,
1.0
/
24
,
1.0
/
(
24
*
60
),
1.0
/
(
24
*
60
*
60
)]
delta_list
=
[
getYearLen
,
getMonthLen
,
1
,
1.0
/
24
,
1.0
/
(
24
*
60
),
1.0
/
(
24
*
60
*
60
)]
@
profiler_decorator
def
countDelimiters
(
value
):
def
countDelimiters
(
value
):
assert
isinstance
(
value
,
basestring
)
assert
isinstance
(
value
,
basestring
)
# Detect if timezone was provided, to avoid counting it as in precision computation.
# Detect if timezone was provided, to avoid counting it as in precision computation.
...
@@ -135,7 +131,6 @@ def countDelimiters(value):
...
@@ -135,7 +131,6 @@ def countDelimiters(value):
last_delimiter
=
None
last_delimiter
=
None
return
delimiter_count
return
delimiter_count
@
profiler_decorator
def
getPeriodBoundaries
(
value
):
def
getPeriodBoundaries
(
value
):
first_date
=
castDate
(
value
,
change_timezone
=
False
)
first_date
=
castDate
(
value
,
change_timezone
=
False
)
if
isinstance
(
value
,
dict
):
if
isinstance
(
value
,
dict
):
...
@@ -152,7 +147,6 @@ def getPeriodBoundaries(value):
...
@@ -152,7 +147,6 @@ def getPeriodBoundaries(value):
delta
=
delta
(
first_date
)
delta
=
delta
(
first_date
)
return
first_date
.
toZone
(
'UTC'
),
(
first_date
+
delta
).
toZone
(
'UTC'
)
return
first_date
.
toZone
(
'UTC'
),
(
first_date
+
delta
).
toZone
(
'UTC'
)
@
profiler_decorator
def
wholePeriod
(
search_key
,
group
,
column
,
value_list
,
exclude
=
False
):
def
wholePeriod
(
search_key
,
group
,
column
,
value_list
,
exclude
=
False
):
if
exclude
:
if
exclude
:
first_operator
=
'<'
first_operator
=
'<'
...
@@ -177,7 +171,6 @@ def matchWholePeriod(search_key, group, column, value_list, *ignored):
...
@@ -177,7 +171,6 @@ def matchWholePeriod(search_key, group, column, value_list, *ignored):
def
matchNotWholePeriod
(
search_key
,
group
,
column
,
value_list
,
*
ignored
):
def
matchNotWholePeriod
(
search_key
,
group
,
column
,
value_list
,
*
ignored
):
return
wholePeriod
(
search_key
,
group
,
column
,
value_list
,
exclude
=
True
)
return
wholePeriod
(
search_key
,
group
,
column
,
value_list
,
exclude
=
True
)
@
profiler_decorator
def
matchExact
(
search_key
,
group
,
column
,
value_list
,
comparison_operator
,
logical_operator
):
def
matchExact
(
search_key
,
group
,
column
,
value_list
,
comparison_operator
,
logical_operator
):
if
comparison_operator
is
None
:
if
comparison_operator
is
None
:
comparison_operator
=
'='
comparison_operator
=
'='
...
@@ -191,11 +184,9 @@ def matchExact(search_key, group, column, value_list, comparison_operator, logic
...
@@ -191,11 +184,9 @@ def matchExact(search_key, group, column, value_list, comparison_operator, logic
def
getNextPeriod
(
value
):
def
getNextPeriod
(
value
):
return
getPeriodBoundaries
(
value
)[
1
]
return
getPeriodBoundaries
(
value
)[
1
]
@
profiler_decorator
def
matchBeforeNextPeriod
(
search_key
,
group
,
column
,
value_list
,
comparison_operator
,
logical_operator
):
def
matchBeforeNextPeriod
(
search_key
,
group
,
column
,
value_list
,
comparison_operator
,
logical_operator
):
return
matchExact
(
search_key
,
group
,
column
,
[
getNextPeriod
(
x
)
for
x
in
value_list
],
'<'
,
logical_operator
)
return
matchExact
(
search_key
,
group
,
column
,
[
getNextPeriod
(
x
)
for
x
in
value_list
],
'<'
,
logical_operator
)
@
profiler_decorator
def
matchAfterPeriod
(
search_key
,
group
,
column
,
value_list
,
comparison_operator
,
logical_operator
):
def
matchAfterPeriod
(
search_key
,
group
,
column
,
value_list
,
comparison_operator
,
logical_operator
):
return
matchExact
(
search_key
,
group
,
column
,
[
getNextPeriod
(
x
)
for
x
in
value_list
],
'>='
,
logical_operator
)
return
matchExact
(
search_key
,
group
,
column
,
[
getNextPeriod
(
x
)
for
x
in
value_list
],
'>='
,
logical_operator
)
...
@@ -275,7 +266,6 @@ class DateTimeKey(SearchKey):
...
@@ -275,7 +266,6 @@ class DateTimeKey(SearchKey):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
return
'"%s"'
%
(
DateTime
(
value
).
ISO
(),
)
return
'"%s"'
%
(
DateTime
(
value
).
ISO
(),
)
@
profiler_decorator
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
column
=
self
.
getColumn
()
column
=
self
.
getColumn
()
query_list
=
[]
query_list
=
[]
...
...
product/ZSQLCatalog/SearchKey/FullTextKey.py
View file @
27f4b03d
...
@@ -33,7 +33,6 @@ from Products.ZSQLCatalog.Query.SimpleQuery import SimpleQuery
...
@@ -33,7 +33,6 @@ from Products.ZSQLCatalog.Query.SimpleQuery import SimpleQuery
from
Products.ZSQLCatalog.SearchText
import
parse
from
Products.ZSQLCatalog.SearchText
import
parse
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
import
re
import
re
FULLTEXT_BOOLEAN_DETECTOR
=
re
.
compile
(
r'.*((^|\
s)[
\+\
-<>
\(\
~]|[
\*\
)](
\s|$))'
)
FULLTEXT_BOOLEAN_DETECTOR
=
re
.
compile
(
r'.*((^|\
s)[
\+\
-<>
\(\
~]|[
\*\
)](
\s|$))'
)
...
@@ -54,7 +53,6 @@ class FullTextKey(SearchKey):
...
@@ -54,7 +53,6 @@ class FullTextKey(SearchKey):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
return
'(%s)'
%
(
value
,
)
return
'(%s)'
%
(
value
,
)
@
profiler_decorator
def
_processSearchValue
(
self
,
search_value
,
logical_operator
,
def
_processSearchValue
(
self
,
search_value
,
logical_operator
,
comparison_operator
):
comparison_operator
):
"""
"""
...
@@ -81,7 +79,6 @@ class FullTextKey(SearchKey):
...
@@ -81,7 +79,6 @@ class FullTextKey(SearchKey):
operator_value_dict
[
'match'
]
=
new_value_list
operator_value_dict
[
'match'
]
=
new_value_list
return
operator_value_dict
,
logical_operator
,
parsed
return
operator_value_dict
,
logical_operator
,
parsed
@
profiler_decorator
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
"""
"""
Special Query builder for FullText queries: merge all values having the
Special Query builder for FullText queries: merge all values having the
...
...
product/ZSQLCatalog/SearchKey/RelatedKey.py
View file @
27f4b03d
...
@@ -36,7 +36,6 @@ from Products.ZSQLCatalog.SQLExpression import SQLExpression
...
@@ -36,7 +36,6 @@ from Products.ZSQLCatalog.SQLExpression import SQLExpression
from
Products.ZSQLCatalog.interfaces.search_key
import
IRelatedKey
from
Products.ZSQLCatalog.interfaces.search_key
import
IRelatedKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
zope.interface
import
implements
from
zope.interface
import
implements
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
from
Products.ZSQLCatalog.TableDefinition
import
TableAlias
,
InnerJoin
,
LeftJoin
from
Products.ZSQLCatalog.TableDefinition
import
TableAlias
,
InnerJoin
,
LeftJoin
from
logging
import
getLogger
from
logging
import
getLogger
...
@@ -68,7 +67,6 @@ class RelatedKey(SearchKey):
...
@@ -68,7 +67,6 @@ class RelatedKey(SearchKey):
related_key_definition
=
None
related_key_definition
=
None
@
profiler_decorator
def
_buildRelatedKey
(
self
,
related_key_definition
):
def
_buildRelatedKey
(
self
,
related_key_definition
):
"""
"""
Extract RelatedKey parameters from its definition, and cache this
Extract RelatedKey parameters from its definition, and cache this
...
@@ -90,7 +88,6 @@ class RelatedKey(SearchKey):
...
@@ -90,7 +88,6 @@ class RelatedKey(SearchKey):
table_list
,
self
.
real_column
,
self
.
related_key_id
=
related_key_definition
.
split
(
'/'
)
table_list
,
self
.
real_column
,
self
.
related_key_id
=
related_key_definition
.
split
(
'/'
)
self
.
table_list
=
table_list
.
split
(
','
)
self
.
table_list
=
table_list
.
split
(
','
)
@
profiler_decorator
def
_getSearchKey
(
self
,
sql_catalog
,
search_key_name
):
def
_getSearchKey
(
self
,
sql_catalog
,
search_key_name
):
"""
"""
Get search key relevant to the actual column.
Get search key relevant to the actual column.
...
@@ -102,7 +99,6 @@ class RelatedKey(SearchKey):
...
@@ -102,7 +99,6 @@ class RelatedKey(SearchKey):
"""
"""
return
sql_catalog
.
getSearchKey
(
self
.
real_column
,
search_key_name
)
return
sql_catalog
.
getSearchKey
(
self
.
real_column
,
search_key_name
)
@
profiler_decorator
def
getSearchKey
(
self
,
sql_catalog
,
related_key_definition
,
search_key_name
=
None
):
def
getSearchKey
(
self
,
sql_catalog
,
related_key_definition
,
search_key_name
=
None
):
"""
"""
Get search key relevant to the actual column, extracting information
Get search key relevant to the actual column, extracting information
...
@@ -118,7 +114,6 @@ class RelatedKey(SearchKey):
...
@@ -118,7 +114,6 @@ class RelatedKey(SearchKey):
self
.
_buildRelatedKey
(
related_key_definition
)
self
.
_buildRelatedKey
(
related_key_definition
)
return
self
.
_getSearchKey
(
sql_catalog
,
search_key_name
)
return
self
.
_getSearchKey
(
sql_catalog
,
search_key_name
)
@
profiler_decorator
def
buildQuery
(
self
,
sql_catalog
,
related_key_definition
,
def
buildQuery
(
self
,
sql_catalog
,
related_key_definition
,
search_value
=
None
):
search_value
=
None
):
self
.
_buildRelatedKey
(
related_key_definition
)
self
.
_buildRelatedKey
(
related_key_definition
)
...
@@ -128,7 +123,6 @@ class RelatedKey(SearchKey):
...
@@ -128,7 +123,6 @@ class RelatedKey(SearchKey):
return
RelatedQuery
(
search_key
=
self
,
return
RelatedQuery
(
search_key
=
self
,
join_condition
=
join_condition
)
join_condition
=
join_condition
)
@
profiler_decorator
def
registerColumnMap
(
self
,
column_map
,
table_alias_list
=
None
):
def
registerColumnMap
(
self
,
column_map
,
table_alias_list
=
None
):
related_column
=
self
.
getColumn
()
related_column
=
self
.
getColumn
()
group
=
column_map
.
registerRelatedKey
(
related_column
,
self
.
real_column
)
group
=
column_map
.
registerRelatedKey
(
related_column
,
self
.
real_column
)
...
@@ -189,7 +183,6 @@ class RelatedKey(SearchKey):
...
@@ -189,7 +183,6 @@ class RelatedKey(SearchKey):
condition
=
join_query_list
[
-
1
]
condition
=
join_query_list
[
-
1
]
return
InnerJoin
(
left
,
right
,
condition
)
return
InnerJoin
(
left
,
right
,
condition
)
@
profiler_decorator
def
buildSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
,
group
):
def
buildSQLExpression
(
self
,
sql_catalog
,
column_map
,
only_group_columns
,
group
):
"""
"""
Render RelatedKey's ZSQLMethod by providing it table aliases from
Render RelatedKey's ZSQLMethod by providing it table aliases from
...
...
product/ZSQLCatalog/SearchKey/SearchKey.py
View file @
27f4b03d
...
@@ -34,7 +34,7 @@ from Products.ZSQLCatalog.Query.ComplexQuery import ComplexQuery
...
@@ -34,7 +34,7 @@ from Products.ZSQLCatalog.Query.ComplexQuery import ComplexQuery
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
zope.interface
import
implements
from
zope.interface
import
implements
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
,
list_type_list
from
Products.ZSQLCatalog.SQLCatalog
import
list_type_list
single_operator_dict
=
{
single_operator_dict
=
{
'min'
:
'>='
,
'min'
:
'>='
,
...
@@ -91,14 +91,12 @@ class SearchKey(object):
...
@@ -91,14 +91,12 @@ class SearchKey(object):
def
getColumn
(
self
):
def
getColumn
(
self
):
return
self
.
column
return
self
.
column
@
profiler_decorator
def
buildSQLExpression
(
self
,
operator
,
value
,
column_map
,
only_group_columns
,
def
buildSQLExpression
(
self
,
operator
,
value
,
column_map
,
only_group_columns
,
group
):
group
):
column_name
=
self
.
getColumn
()
column_name
=
self
.
getColumn
()
rendered_column
=
column_map
.
asSQLColumn
(
column_name
,
group
=
group
)
rendered_column
=
column_map
.
asSQLColumn
(
column_name
,
group
=
group
)
return
operator
.
asSQLExpression
(
rendered_column
,
value
,
only_group_columns
)
return
operator
.
asSQLExpression
(
rendered_column
,
value
,
only_group_columns
)
@
profiler_decorator
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
"""
"""
Render a single value as valid SearchText using provided operator.
Render a single value as valid SearchText using provided operator.
...
@@ -115,7 +113,6 @@ class SearchKey(object):
...
@@ -115,7 +113,6 @@ class SearchKey(object):
value
=
operator_value_deprocessor
(
value
)
value
=
operator_value_deprocessor
(
value
)
return
operator
.
asSearchText
(
value
)
return
operator
.
asSearchText
(
value
)
@
profiler_decorator
def
buildSearchTextExpression
(
self
,
operator
,
value
,
column
=
None
):
def
buildSearchTextExpression
(
self
,
operator
,
value
,
column
=
None
):
operator_text
=
operator
.
getOperatorSearchText
()
operator_text
=
operator
.
getOperatorSearchText
()
if
column
is
None
:
if
column
is
None
:
...
@@ -137,13 +134,11 @@ class SearchKey(object):
...
@@ -137,13 +134,11 @@ class SearchKey(object):
result
=
'%s:%s'
%
(
column
,
result
)
result
=
'%s:%s'
%
(
column
,
result
)
return
result
return
result
@
profiler_decorator
def
registerColumnMap
(
self
,
column_map
,
group
,
simple_query
):
def
registerColumnMap
(
self
,
column_map
,
group
,
simple_query
):
column_map
.
registerColumn
(
self
.
getColumn
(),
group
=
group
,
column_map
.
registerColumn
(
self
.
getColumn
(),
group
=
group
,
simple_query
=
simple_query
)
simple_query
=
simple_query
)
return
group
return
group
@
profiler_decorator
def
_getComparisonOperator
(
self
,
value
):
def
_getComparisonOperator
(
self
,
value
):
"""
"""
From a basestring instance, return a contained operator and value
From a basestring instance, return a contained operator and value
...
@@ -164,7 +159,6 @@ class SearchKey(object):
...
@@ -164,7 +159,6 @@ class SearchKey(object):
operator
=
self
.
_guessComparisonOperator
(
value
)
operator
=
self
.
_guessComparisonOperator
(
value
)
return
operator
,
value
return
operator
,
value
@
profiler_decorator
def
_guessComparisonOperator
(
self
,
value
):
def
_guessComparisonOperator
(
self
,
value
):
"""
"""
From a basestring instance, return an operator.
From a basestring instance, return an operator.
...
@@ -176,7 +170,6 @@ class SearchKey(object):
...
@@ -176,7 +170,6 @@ class SearchKey(object):
"""
"""
return
self
.
default_comparison_operator
return
self
.
default_comparison_operator
@
profiler_decorator
def
_preprocessValue
(
self
,
value
,
operator
):
def
_preprocessValue
(
self
,
value
,
operator
):
operator_value_preprocessor
=
operator_value_preprocessor_dict
.
get
(
operator_value_preprocessor
=
operator_value_preprocessor_dict
.
get
(
operator
)
operator
)
...
@@ -184,7 +177,6 @@ class SearchKey(object):
...
@@ -184,7 +177,6 @@ class SearchKey(object):
value
=
operator_value_preprocessor
(
value
)
value
=
operator_value_preprocessor
(
value
)
return
value
return
value
@
profiler_decorator
def
_processSearchValue
(
self
,
search_value
,
default_logical_operator
,
def
_processSearchValue
(
self
,
search_value
,
default_logical_operator
,
comparison_operator
):
comparison_operator
):
"""
"""
...
@@ -325,7 +317,6 @@ class SearchKey(object):
...
@@ -325,7 +317,6 @@ class SearchKey(object):
operator_value_dict
[
comparison_operator
]
=
search_value
operator_value_dict
[
comparison_operator
]
=
search_value
return
operator_value_dict
,
logical_operator
,
parsed
return
operator_value_dict
,
logical_operator
,
parsed
@
profiler_decorator
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
"""
"""
Create Queries from values, logical and comparison operators.
Create Queries from values, logical and comparison operators.
...
@@ -354,7 +345,6 @@ class SearchKey(object):
...
@@ -354,7 +345,6 @@ class SearchKey(object):
group
=
group
,
**
{
column
:
value
}))
group
=
group
,
**
{
column
:
value
}))
return
query_list
return
query_list
@
profiler_decorator
def
buildQuery
(
self
,
search_value
,
group
=
None
,
logical_operator
=
None
,
def
buildQuery
(
self
,
search_value
,
group
=
None
,
logical_operator
=
None
,
comparison_operator
=
None
):
comparison_operator
=
None
):
assert
logical_operator
in
(
None
,
'and'
,
'or'
),
repr
(
logical_operator
)
assert
logical_operator
in
(
None
,
'and'
,
'or'
),
repr
(
logical_operator
)
...
...
product/ZSQLCatalog/SearchKey/SphinxSEFullTextKey.py
View file @
27f4b03d
...
@@ -30,7 +30,6 @@ from Products.ZSQLCatalog.Query.SimpleQuery import SimpleQuery
...
@@ -30,7 +30,6 @@ from Products.ZSQLCatalog.Query.SimpleQuery import SimpleQuery
from
Products.ZSQLCatalog.SearchText
import
parse
from
Products.ZSQLCatalog.SearchText
import
parse
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
class
SphinxSEFullTextKey
(
SearchKey
):
class
SphinxSEFullTextKey
(
SearchKey
):
"""
"""
...
@@ -48,7 +47,6 @@ class SphinxSEFullTextKey(SearchKey):
...
@@ -48,7 +47,6 @@ class SphinxSEFullTextKey(SearchKey):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
def
_renderValueAsSearchText
(
self
,
value
,
operator
):
return
'(%s)'
%
(
value
,
)
return
'(%s)'
%
(
value
,
)
@
profiler_decorator
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
def
_buildQuery
(
self
,
operator_value_dict
,
logical_operator
,
parsed
,
group
):
"""
"""
Special Query builder for FullText queries: merge all values having the
Special Query builder for FullText queries: merge all values having the
...
...
product/ZSQLCatalog/SearchText/SearchTextParser.py
View file @
27f4b03d
...
@@ -32,11 +32,6 @@ import threading
...
@@ -32,11 +32,6 @@ import threading
from
AdvancedSearchTextDetector
import
AdvancedSearchTextDetector
from
AdvancedSearchTextDetector
import
AdvancedSearchTextDetector
from
AdvancedSearchTextParser
import
AdvancedSearchTextParser
from
AdvancedSearchTextParser
import
AdvancedSearchTextParser
from
lexer
import
ParserOrLexerError
from
lexer
import
ParserOrLexerError
try
:
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
except
ImportError
:
def
profiler_decorator
(
funct
):
return
funct
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
DEBUG
=
1
DEBUG
=
1
...
@@ -90,11 +85,9 @@ def safeParsingDecorator(func):
...
@@ -90,11 +85,9 @@ def safeParsingDecorator(func):
wrapper
.
__name__
=
func
.
__name__
wrapper
.
__name__
=
func
.
__name__
return
wrapper
return
wrapper
@
profiler_decorator
def
isAdvancedSearchText
(
input
,
is_column
):
def
isAdvancedSearchText
(
input
,
is_column
):
return
parser_pool
.
get
(
DETECTOR_ID
)(
input
,
is_column
)
return
parser_pool
.
get
(
DETECTOR_ID
)(
input
,
is_column
)
@
profiler_decorator
@
safeParsingDecorator
@
safeParsingDecorator
def
parse
(
input
,
is_column
,
*
args
,
**
kw
):
def
parse
(
input
,
is_column
,
*
args
,
**
kw
):
if
isAdvancedSearchText
(
input
,
is_column
):
if
isAdvancedSearchText
(
input
,
is_column
):
...
...
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