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