[Erp5-report] r13339 - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Mar 12 11:10:32 CET 2007
Author: jp
Date: Mon Mar 12 11:10:31 2007
New Revision: 13339
URL: http://svn.erp5.org?rev=13339&view=rev
Log:
Added support for simple types (ex. int) passed as arguments as well as analysis of OR keyword in a string so that it is possible to pass mutliple values through a single string.
Modified:
erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=13339&r1=13338&r2=13339&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py Mon Mar 12 11:10:31 2007
@@ -105,6 +105,12 @@
self._setObject(id, c)
if REQUEST is not None:
return self.manage_main(self, REQUEST,update_menu=1)
+
+def isSimpleType(value):
+ return isinstance(value, basestring) or \
+ isinstance(value, int) or \
+ isinstance(value, long) or \
+ isinstance(value, float)
class UidBuffer(TM):
@@ -221,6 +227,17 @@
def getSearchMode(self):
return self.search_mode
+
+ def asSearchTextExpression(self):
+ # This will be the standard way to represent
+ # complex values in listbox. Some fixed
+ # point must be garanteed
+ value = self.value
+ if isSimpleType(value) or isinstance(value, DateTime):
+ return str(value)
+ elif isinstance(value, (list, tuple)):
+ value = map(lambda x:str(x), value)
+ return (' %s ' % self.operator).join(value)
def asSQLExpression(self, key_alias_dict=None,
keyword_search_keys=None,
@@ -263,10 +280,16 @@
where_expression.append("%s >= '%s' and %s <= '%s'" % (key, query_min, key, query_max))
elif range_value == 'ngt' :
where_expression.append("%s <= '%s'" % (key, query_max))
- elif isinstance(value, basestring) or isinstance(value, DateTime) \
+ elif isSimpleType(value) or isinstance(value, DateTime) \
or isinstance(value, (list, tuple)):
+ # Convert into lists any value which contain a ;
+ # Refer to _listGlobalActions DCWorkflow patch
+ # for example of use
+ if isinstance(value, basestring):
+ value = value.split('OR')
+ value = map(lambda x:x.strip(), value)
value_list = value
- if isinstance(value, basestring) or isinstance(value, DateTime):
+ if isSimpleType(value) or isinstance(value, DateTime):
value_list = [value]
# For security.
for value in value_list:
More information about the Erp5-report
mailing list