# HG changeset patch # User root@xserve09.mpiwg-berlin.mpg.de # Date 1297970298 -3600 # Node ID 87087f4f405906fc86c46714114e55d0b4fb5832 # Parent 17b19345d011d66b4db0fb6392600347da492d10 fixed bug with default sort order. diff -r 17b19345d011 -r 87087f4f4059 ZDBInterfaceFolder.py --- a/ZDBInterfaceFolder.py Thu Feb 17 19:25:16 2011 +0100 +++ b/ZDBInterfaceFolder.py Thu Feb 17 20:18:18 2011 +0100 @@ -26,13 +26,16 @@ manage_editZDBInterfaceFolderForm=PageTemplateFile('zpt/editZDBInterfaceFolder',globals()) - def __init__(self, id, title, connection_id=None, autocommit=False): + def __init__(self, id, title, connection_id=None, autocommit=False, default_search='bw'): """init""" self.id = id self.title = title # database connection id self.connection_id = connection_id + # set db connection to autocommit self.autocommit = autocommit + # default text search mode + self.default_search = default_search def getSQLQuery(self, table, argv): """returns dict with SQL query string and args""" @@ -68,10 +71,10 @@ elif op == "gt": wheres.append(param + " > %s") args.append(val) - elif op == "bw": + elif op == "ew": wheres.append(param + " ILIKE %s") args.append("%" + val) - elif op == "ew": + elif op == "bw": wheres.append(param + " ILIKE %s") args.append(val + "%") elif op == "ct": @@ -96,8 +99,10 @@ # evaluate argv for (key, val) in argv.items(): + logging.debug("process key=%s val=%s"%(key,val)) if key in processed: # parameter has been processed + logging.debug(" key=%s processed"%(key)) continue # beginning of a command should always be "_" @@ -135,9 +140,10 @@ # process remaining parameters (without _op) for (key, val) in unprocessed.items(): - param = sqlName(key) - # default is begins-with - doOp("bw", param, val) + if key not in processed: + param = sqlName(key) + # default operation + doOp(self.default_search, param, val) # join it all query = "SELECT %s FROM %s"%(select, table) @@ -161,16 +167,19 @@ result = self.executeZSQL(query['query'], query['args']) return result - def manage_editZDBInterfaceFolder(self, title=None, connection_id=None, autocommit=None, + def manage_editZDBInterfaceFolder(self, title=None, connection_id=None, autocommit=None, default_search=None, REQUEST=None): """Change the object""" - logging.debug("editZDBInterfaceFolder title=%s, connection_id=%s, autocommit=%s"%(title,connection_id,autocommit)) + logging.debug("editZDBInterfaceFolder title=%s, connection_id=%s, autocommit=%s default_search=%s"%(title,connection_id,autocommit,default_search)) if title is not None: self.title = title if connection_id is not None: self.connection_id = connection_id + if default_search is not None: + self.default_search = default_search + self.autocommit = (autocommit == "on") #checkPermission=getSecurityManager().checkPermission diff -r 17b19345d011 -r 87087f4f4059 zpt/editZDBInterfaceFolder.zpt --- a/zpt/editZDBInterfaceFolder.zpt Thu Feb 17 19:25:16 2011 +0100 +++ b/zpt/editZDBInterfaceFolder.zpt Thu Feb 17 20:18:18 2011 +0100 @@ -16,5 +16,11 @@

autocommit (don't use when you want transactions)

+

Default search mode

+

+ +