[Erp5-report] r19216 - /erp5/trunk/products/ZSQLCatalog/SearchKey/
nobody at svn.erp5.org
nobody at svn.erp5.org
Sun Feb 10 15:37:24 CET 2008
Author: jp
Date: Sun Feb 10 15:37:23 2008
New Revision: 19216
URL: http://svn.erp5.org?rev=19216&view=rev
Log:
more spaces removed
Modified:
erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py?rev=19216&r1=19215&r2=19216&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py Sun Feb 10 15:37:23 2008
@@ -33,14 +33,14 @@
from SearchKey import SearchKey
from pprint import pprint
-
+
class DateTimeKey(SearchKey):
""" DateTimeKey key is an ERP5 portal_catalog search key which is used to render
SQL expression that will try to match values in DateTime MySQL columns.
It supports following special operator ['=', '%', '>' , '>=', '<', '<='] in
addition to main logical operators like ['OR', 'or', 'AND', 'and'].
- Note: because all ERP5 datetime values are indexed in MySQL in 'UTC'
+ Note: because all ERP5 datetime values are indexed in MySQL in 'UTC'
the respective passed date will be first converted to 'UTC' before inserted into
respective SQL query!
@@ -48,15 +48,15 @@
* '15/01/2008' --> "delivery.start_date = '2008-01-14 22:00'"
- * '>=15/01/2008' --> "delivery.start_date >= '2008-01-14 22:00'"
+ * '>=15/01/2008' --> "delivery.start_date >= '2008-01-14 22:00'"
- * '>=15/01/2008 or <=20/01/2008'
+ * '>=15/01/2008 or <=20/01/2008'
--> "delivery.start_date >= '2008-01-14 22:00' or delivery.start_date<='2008-01-19 22:00'"
* '>=15/01/2008 10:00 GMT+02 OR <=20/01/2008 05:12 Universal'
-->
- "delivery.start_date >= '2008-01-15 08:00 Universal'
- OR
+ "delivery.start_date >= '2008-01-15 08:00 Universal'
+ OR
delivery.start_date <= '2008-01-20 05:12 Universal'
"
"""
@@ -65,7 +65,7 @@
'GREATERTHAN', 'GREATERTHANEQUAL',
'LESSTHAN', 'LESSTHANEQUAL')
- sub_operators = ('GREATERTHAN', 'GREATERTHANEQUAL',
+ sub_operators = ('GREATERTHAN', 'GREATERTHANEQUAL',
'LESSTHAN', 'LESSTHANEQUAL', 'NOT', 'EQUAL',)
def t_OR(self, t):
@@ -86,15 +86,15 @@
t.value = t.value.upper().strip()
return t
- t_GREATERTHANEQUAL = r'>='
- t_LESSTHANEQUAL = r'<='
+ t_GREATERTHANEQUAL = r'>='
+ t_LESSTHANEQUAL = r'<='
t_GREATERTHAN = r'>'
t_LESSTHAN = r'<'
t_EQUAL = r'='
t_DATE = r'\d{1,4}[(/|\.|\-) /.]\d{1,4}[(/|\.|\-) /.]\d{1,4}((\s.)*\d{0,2}:\d{0,2}(:\d{0,2})?)?(\sUniversal|\sGMT\+\d\d)?|\d\d\d\d%?'
def quoteSQLString(self, value, format):
- """ Return a quoted string of the value.
+ """ Return a quoted string of the value.
Make sure to convert it to UTC first."""
if getattr(value, 'ISO', None) is not None:
value = "'%s'" % value.toZone('UTC').ISO()
@@ -122,7 +122,7 @@
# add days ofset accordingly
format = '%%%s/%%m/%%d' %format
date_value = '%s/01/01' %date_value
- days_offset_map = {'=' : 366, '>' : 366,
+ days_offset_map = {'=' : 366, '>' : 366,
'>=' : 366, '<': -366, '<=':-366}
days_offset = days_offset_map[sub_operator]
@@ -143,10 +143,10 @@
if sub_operator == '=':
# transform to range 'key >= date AND date < key'
query_kw = {key: (date_value, date_value + days_offset,),
- 'range': 'minmax'}
+ 'range': 'minmax'}
else:
query_kw = {key: date_value + days_offset,
- 'range': sub_operator}
+ 'range': sub_operator}
query_kw['type'] = 'date'
else:
# not a valid date, try to get an year range
@@ -159,7 +159,7 @@
date_value = DateTime(date_value).toZone('UTC')
query_kw = {key: (date_value, date_value + 366,),
'type': 'date',
- 'range': 'minmax'}
+ 'range': 'minmax'}
# append only if it was possible to generate query
if query_kw is not None:
@@ -167,7 +167,7 @@
# join query list in one really big ComplexQuery
if len(query_list):
- complex_query = ComplexQuery(*query_list,
+ complex_query = ComplexQuery(*query_list,
**{'operator': 'AND'})
return complex_query
@@ -188,7 +188,7 @@
## operator_value = operator.value
## where_expressions.append('%s' %operator_value)
## if len(tokens):
-## # no it's not a stand alone expression,
+## # no it's not a stand alone expression,
## # determine it from list of tokens
## operator_value, sub_tokens = self.getOperatorForTokenList(tokens)
## row_tokens_values = [self.quoteSQLString(x.value, format) for x in sub_tokens]
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py?rev=19216&r1=19215&r2=19216&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py Sun Feb 10 15:37:23 2008
@@ -25,7 +25,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
-
+
from SearchKey import SearchKey
from pprint import pprint
@@ -35,7 +35,7 @@
It supports following special operator ['=', '%', '>' , '>=', '<', '<='] in
addition to main logical operators like ['OR', 'or', 'AND', 'and'].
- Examples for title column:
+ Examples for title column:
* 'foo or bar' --> "title = 'foo' OR title = 'bar'"
* 'foo or =bar' --> "title = 'foo' OR title = 'bar'"
* '%foo% or bar' --> "title = '%foo%' OR title = 'bar'"
@@ -48,10 +48,10 @@
default_key_type = 'default'
tokens = ('OR', 'AND', 'NOT', 'WORDSET', 'WORD',
- 'GREATERTHAN', 'GREATERTHANEQUAL',
+ 'GREATERTHAN', 'GREATERTHANEQUAL',
'LESSTHAN', 'LESSTHANEQUAL')
- sub_operators = ('GREATERTHAN', 'GREATERTHANEQUAL',
+ sub_operators = ('GREATERTHAN', 'GREATERTHANEQUAL',
'LESSTHAN', 'LESSTHANEQUAL', 'NOT')
@@ -68,19 +68,19 @@
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'AND'
- return t
+ return t
def t_NOT(self, t):
r'(\s+NOT\s+|\s+not\s+|!=)'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
- t.value = '!='
- return t
+ t.value = '!='
+ return t
- t_GREATERTHANEQUAL = r'>='
- t_LESSTHANEQUAL = r'<='
+ t_GREATERTHANEQUAL = r'>='
+ t_LESSTHANEQUAL = r'<='
t_GREATERTHAN = r'>'
- t_LESSTHAN = r'<'
+ t_LESSTHAN = r'<'
def t_WORD(self, t):
r'[\x7F-\xFF\w\d\/~!@#$%^&*()_+\n][\x7F-\xFF\w\d\/~!@#$%^&*()_+\n]*'
@@ -98,7 +98,7 @@
# and starting/ending with "
value = t.value.replace('"', '').strip()
t.value = "%s" %value
- return t
+ return t
def quoteSQLString(self, value, format):
""" Return a quoted string of the value. """
@@ -139,9 +139,9 @@
## operator_value = operator.value
## where_expressions.append('%s' %operator_value)
## if len(tokens):
-## # no it's not a stand alone expression,
+## # no it's not a stand alone expression,
## # determine it from list of tokens
## operator_value, sub_tokens = self.getOperatorForTokenList(tokens)
## row_tokens_values = [x.value for x in sub_tokens]
## where_expressions.append("%s %s '%s'" %(key, operator_value, ' '.join(row_tokens_values)))
-## return where_expressions, select_expressions
+## return where_expressions, select_expressions
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py?rev=19216&r1=19215&r2=19216&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py Sun Feb 10 15:37:23 2008
@@ -33,13 +33,13 @@
class FullTextKey(SearchKey):
""" FullTextKey key is an ERP5 portal_catalog search key which is used to render
- SQL expression that will try match all possible values using
+ SQL expression that will try match all possible values using
MySQL's fulltext search support.
- See syntax see MySQL's FullText search reference:
+ See syntax see MySQL's FullText search reference:
http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
"""
- tokens = ('PLUS', 'MINUS', 'WORD', 'GREATERTHAN', 'LESSTHAN', 'LEFTPARENTHES',
+ tokens = ('PLUS', 'MINUS', 'WORD', 'GREATERTHAN', 'LESSTHAN', 'LEFTPARENTHES',
'RIGHTPARENTHES', 'TILDE', 'ASTERISK', 'DOUBLEQUOTE',)
# SQL expressions patterns
@@ -50,12 +50,12 @@
t_PLUS = r'(\+)'
t_MINUS = r'(\-)'
t_GREATERTHAN = r'(\>)'
- t_LESSTHAN = r'(\<)'
- t_LEFTPARENTHES = r'(\()'
+ t_LESSTHAN = r'(\<)'
+ t_LEFTPARENTHES = r'(\()'
t_RIGHTPARENTHES = r'(\))'
- t_TILDE = r'(\~)'
+ t_TILDE = r'(\~)'
t_ASTERISK = r'(\*)'
- t_DOUBLEQUOTE = r'(\")'
+ t_DOUBLEQUOTE = r'(\")'
def t_WORD(self, t):
r'[\x7F-\xFF\w\d\/!@#$%^&_][\x7F-\xFF\w\d\/!@#$%^&_]*'
@@ -65,15 +65,15 @@
t.value = "'%s'" %word_value
return t
- def buildSQLExpression(self, key, value,
+ def buildSQLExpression(self, key, value,
format=None, mode=None, range_value=None, stat__=None):
""" Analize token list and generate SQL expressions."""
tokens = self.tokenize(value)
# based on type tokens we may switch to different search mode
mode = SEARCH_MODE_MAPPING.get(mode, '')
if mode == '':
- # determine it based on list of tokens i.e if we have only words
- # leave as its but if we have '-' or '+' use boolean mode
+ # determine it based on list of tokens i.e if we have only words
+ # leave as its but if we have '-' or '+' use boolean mode
for token in tokens:
if token.type != 'WORD':
mode = SEARCH_MODE_MAPPING['in_boolean_mode']
@@ -90,7 +90,7 @@
where_expression = self.where_match_against %(key, value, mode)
if not stat__:
# stat__ is an internal implementation artifact to prevent adding
- # select_expression for countFolder
+ # select_expression for countFolder
select_expression_list = [self.select_match_against_as %(key, value, mode, relevance_key1),]
if relevance_key2 is not None:
select_expression_list.append(self.select_match_against_as %(key, value, mode, relevance_key2))
More information about the Erp5-report
mailing list