--- ZSQLExtend/ZSQLExtend.py 2008/03/31 13:31:34 1.126 +++ ZSQLExtend/ZSQLExtend.py 2009/09/30 15:29:14 1.131 @@ -423,6 +423,7 @@ class ZSQLExtendFolder(Folder,Persistent # set up logging to response as plain text RESPONSE.setHeader("Content-Type","text/plain; charset=utf-8") RESPONSE.write("Import FMPXML file...\n\n") + RESPONSE.flush() loghandler = logging.StreamHandler(RESPONSE) if debug: loghandler.setLevel(logging.DEBUG) @@ -579,9 +580,9 @@ class ZSQLExtendFolder(Folder,Persistent @param str: string der Formatiert werden soll. @param url: (optional) default ist "None", sonderfall erzeugt einen Link aus String mit unterliegender url """ - #logging.debug("formatascii str=%s url=%s"%(repr(str),repr(url))) + #logging.debug("formatascii str=%s url=%s"%(repr(str),repr(url))) - if not str: + if not str: return "" str=str.rstrip().lstrip() @@ -662,6 +663,7 @@ class ZSQLExtendFolder(Folder,Persistent @param _value: String der gesucht werden soll, gesucht wird nach allen Worten des Strings, die durch " "-getrennt sind. @param _idField: Feld mit id fŸr die identifikation gleicher EintrŠge @param _additionalStatement: (optional) Zusaetzliches SQL Statement, dass zwischen dem ersten "select from" und dem ersten "where" eingegefŸgt wird. + @param _subselectAddition: (optiona) Zusaetliche SQL Statement die hinter das select statement der subselects eingefuegt werde. @param _select: (optional) Alternativer Wert fŸr den ersten SELECT Aufruf. @param _storename: (optional) Name fuer die Zwischenspeicherung von Werten in der Session """ @@ -873,7 +875,7 @@ class ZSQLExtendFolder(Folder,Persistent #print "INLINE:",argv for a in argTmp.keys(): - aFiltered=re.sub(r"^-","_",a) # beginning of a command should always be "_" + aFiltered=re.sub(r"^-","_",a) # beginning of a command should always be "_" qs.append(aFiltered+"="+urllib.quote(str(argTmp[a]))) #return [] ret = self.parseQueryString(string.join(qs,","),"_",storename=storename) @@ -1036,18 +1038,19 @@ class ZSQLExtendFolder(Folder,Persistent - def ZSQLAdd(self,format=None,RESPONSE=None,args=None,**argv): + def ZSQLAdd(self,format=None,RESPONSE=None,args=None,_useRequest=True,**argv): """Neuer Eintrag""" - if args: + if args: argTmp=args else: argTmp=argv qs_temp=[] - for a in self.REQUEST.form.keys(): - qs_temp.append(a+"="+urllib.quote(str(self.REQUEST.form[a]))) + if _useRequest: + for a in self.REQUEST.form.keys(): + qs_temp.append(a+"="+urllib.quote(str(self.REQUEST.form[a]))) qs=string.join(qs_temp,",") @@ -1062,7 +1065,10 @@ class ZSQLExtendFolder(Folder,Persistent addList={} for q in qs.split(","): + if len(q.split("="))<2: + continue name=re.sub("r'+'"," ",q.split("=")[0].lower()) + value=q.split("=")[1] value=re.sub(r'\+'," ",value) value=urllib.unquote(value) @@ -1131,16 +1137,19 @@ class ZSQLExtendFolder(Folder,Persistent table=urllib.unquote(value) elif name=="-identify": identify=urllib.unquote(value) - identify="lower("+identify.split("=")[0]+")="+sql_quote(identify.split("=")[1].lower()) + # old code did identify with lower() which doesn't work for oids + #identify="lower("+identify.split("=")[0]+")="+sql_quote(identify.split("=")[1].lower()) + (k,v) = identify.split("=") + identify="%s=%s"%(k,sql_quote(v)) elif name=="-format": format=urllib.unquote(value) #elif (not (name[0]=="-" or name[0]=="_")) and (not len(value)==0): elif (not (name[0]=="-" or name[0]=="_")): - if value=="": - changeList.append("\""+name+"\"=null") - else: - changeList.append("\""+name+"\"="+sql_quote(urllib.unquote(value))) + if value=="": + changeList.append("\""+name+"\"=null") + else: + changeList.append("\""+name+"\"="+sql_quote(urllib.unquote(value))) changeString=string.join(changeList,",") @@ -1497,7 +1506,7 @@ class ZSQLExtendFolder(Folder,Persistent elif op=="numerical": term=analyseIntSearch(value) - tmp=(name+" "+term) + tmp=(namealt+" "+term) # take namealt without LOWER elif op=="grep": tmp=(name+" ~* "+sql_quote(value)) elif op=="one": @@ -1547,7 +1556,7 @@ class ZSQLExtendFolder(Folder,Persistent elif op=="numerical": term=analyseIntSearch(value) - tmp=(name+" "+term) + tmp=(namealt+" "+term) # take namealt without LOWER elif op=="grep": tmp=(name+" ~* "+sql_quote(value)) elif op=="one":