Diff for /ZSQLExtend/ZSQLExtend.py between versions 1.5 and 1.9

version 1.5, 2004/01/21 16:54:45 version 1.9, 2004/02/05 10:29:56
Line 18  class ZSQLExtendFolder(Persistent, Impli Line 18  class ZSQLExtendFolder(Persistent, Impli
     """Folder"""      """Folder"""
     meta_type="ZSQLExtendFolder"      meta_type="ZSQLExtendFolder"
           
       def actualPath(self,url=None):
       """path"""
       if not url:
           return "http://"+self.REQUEST['HTTP_X_FORWARDED_SERVER']+self.REQUEST['PATH_TRANSLATED']
           else:
           temp=self.REQUEST[url].split("/")
           temp[2]=self.REQUEST['HTTP_X_FORWARDED_SERVER']
           return string.join(temp,"/")
   
       def getRequest(self):
       """request"""
       return self.REQUEST
   
     def lowerEnd(self,path):      def lowerEnd(self,path):
         """oinly for demo"""          """oinly for demo"""
Line 25  class ZSQLExtendFolder(Persistent, Impli Line 37  class ZSQLExtendFolder(Persistent, Impli
                   
     def ZSQLisEmpty(self,field):      def ZSQLisEmpty(self,field):
         """Teste ob Treffer leer"""          """Teste ob Treffer leer"""
         print "field",field          #print "field",field
         if not field:          if not field:
             return 1              return 1
         if field=="":          if field=="":
             return 1              return 1
         return 0          return 0
   
     def ZSQLsearchOptions(self):      def ZSQLsearchOptions(self,fieldname=""):
         """return HTML Fragment with search options"""          """return HTML Fragment with search options"""
         ret="""<select name="-op">      
           ret="""<select name="-op_%s">
     <option value="bw">begins with</option>             <!-- begins with / beginnt mit, "Wort*" -->      <option value="bw">begins with</option>             <!-- begins with / beginnt mit, "Wort*" -->
     <option value="ew">ends with</option>      <option value="ew">ends with</option>
     <option value="cn">contains</option>                <!-- contains / enthaellt, "Wort" -->      <option value="ct" selected>contains</option>               <!-- contains / enthaellt, "Wort" -->
     <option value="eq">equals</option>                  <!-- equals / ist, =Wort -->      <option value="eq">equals</option>                  <!-- equals / ist, =Wort -->
 </select>"""  </select>"""%fieldname
         return ret          return ret
           
     def ZSQLInlineSearch(self,storename=None,**argv):      def ZSQLInlineSearch(self,storename=None,**argv):
Line 172  class ZSQLExtendFolder(Persistent, Impli Line 185  class ZSQLExtendFolder(Persistent, Impli
         else:          else:
             qs=string.join(qs.split("&"),",")              qs=string.join(qs.split("&"),",")
   
   
         qs=re.sub("\\+"," ",qs)# Austauschen da Leerzeichen bei http-get durch + ersetzt wird, generell sollte alles auf post umgeschrieben werden. vom search formular.          qs=re.sub("\\+"," ",qs)# Austauschen da Leerzeichen bei http-get durch + ersetzt wird, generell sollte alles auf post umgeschrieben werden. vom search formular.
         #print "QS",qs          #print "QS",qs
         if storename:          if storename:
Line 253  class ZSQLExtendFolder(Persistent, Impli Line 267  class ZSQLExtendFolder(Persistent, Impli
             select="*"              select="*"
         #print "Q",nostore,qs          #print "Q",nostore,qs
         #check for op in the case of inline search          #check for op in the case of inline search
         if iCT=="_":                      
             for q in qs.split(","):      splitted=qs.split(",")
       
               
           for q in splitted:
                                   
                 name=re.sub("r'+'"," ",q.split("=")[0].lower())                  name=re.sub("r'+'"," ",q.split("=")[0].lower())
                 value=urllib.unquote(q.split("=")[1])                  value=urllib.unquote(q.split("=")[1])
Line 264  class ZSQLExtendFolder(Persistent, Impli Line 281  class ZSQLExtendFolder(Persistent, Impli
                     field=name[4:]                      field=name[4:]
                     opfields[field]=op                      opfields[field]=op
   
       #print opfieldsa
         #now analyse the querystring          #now analyse the querystring
         for q in qs.split(","):          for q in qs.split(","):
                           
Line 301  class ZSQLExtendFolder(Persistent, Impli Line 319  class ZSQLExtendFolder(Persistent, Impli
   
   
             elif (not name[0]==iCT) and (not len(value)==0):              elif (not name[0]==iCT) and (not len(value)==0):
                 name="LOWER("+name+")"                  
           #print "OP",op,name
                 value=value.lower()                  value=value.lower()
                 if opfields.has_key(name):                  if opfields.has_key(name):
                     op=opfields[name]                      op=opfields[name]
           else:
               op="ct"
           name="LOWER("+name+")"    
                 if op=="ct":                  if op=="ct":
                     whereList.append(name+" LIKE "+libpq.PgQuoteString("%"+value+"%"))                      whereList.append(name+" LIKE "+libpq.PgQuoteString("%"+value+"%"))
                 elif op=="gt":                  elif op=="gt":
Line 331  class ZSQLExtendFolder(Persistent, Impli Line 353  class ZSQLExtendFolder(Persistent, Impli
         if not nostore=="yes":          if not nostore=="yes":
                           
             self.REQUEST.SESSION['qs']=opfields              self.REQUEST.SESSION['qs']=opfields
         print "IAMHERE again:", query          #print "IAMHERE again:", query
   
         if storename:          if storename:
             query2="SELECT count(%s) FROM %s %s"%(select,table,where)              query2="SELECT count(*) FROM %s %s"%(table,where)
             #print "storing",query2              #print "storing",query2
             #print "QUERYSTRING:",self.REQUEST.SESSION[storename]['queryString2']              #print "QUERYSTRING:",self.REQUEST.SESSION[storename]['queryString2']
             if not self.REQUEST.SESSION.has_key(storename):              if not self.REQUEST.SESSION.has_key(storename):
Line 360  class ZSQLExtendFolder(Persistent, Impli Line 382  class ZSQLExtendFolder(Persistent, Impli
                 self.REQUEST.SESSION[storename]['rangeEnd']=int(rangeStart)+int(limit)                  self.REQUEST.SESSION[storename]['rangeEnd']=int(rangeStart)+int(limit)
             self.REQUEST.SESSION[storename]['rangeSize']=limit              self.REQUEST.SESSION[storename]['rangeSize']=limit
                           
                   #print query            
         return self.search(var=query)          return self.search(var=query)
           
     def ZSQLSearch(self):      def ZSQLSearch(self):
Line 433  class ZSQLExtendFolder(Persistent, Impli Line 455  class ZSQLExtendFolder(Persistent, Impli
             newquery.append(query)              newquery.append(query)
                                   
         newquerystring=string.join(newquery,"&")          newquerystring=string.join(newquery,"&")
         return "<a href='%s'>%s</a>"%(self.REQUEST['URL0']+"?"+newquerystring,html)      
           return "<a href='%s'>%s</a>"%(self.actualPath()+"?"+newquerystring,html)
                           
                   
     def prevLink(self,html,storename="foundCount"):      def prevLink(self,html,storename="foundCount"):
Line 484  class ZSQLExtendFolder(Persistent, Impli Line 507  class ZSQLExtendFolder(Persistent, Impli
             newquery.append(query)              newquery.append(query)
                           
         newquerystring=string.join(newquery,"&")          newquerystring=string.join(newquery,"&")
         return "<a href='%s'>%s</a>"%(self.REQUEST['URL0']+"?"+newquerystring,html)  
           return "<a href='%s'>%s</a>"%(self.actualPath()+"?"+newquerystring,html)
   
   
           
     def prevLink_old(self,html):      def prevLink_old(self,html):
         """prev link"""          """prev link"""
Line 511  class ZSQLExtendFolder(Persistent, Impli Line 537  class ZSQLExtendFolder(Persistent, Impli
         else:          else:
             queries.append("-offset=%i"%offsetnew)              queries.append("-offset=%i"%offsetnew)
             newquerystring=string.join(queries,"&")              newquerystring=string.join(queries,"&")
         return "<a href='%s'>%s</a>"%(self.REQUEST['URL0']+"?"+newquerystring,html)          return "<a href='%s'>%s</a>"%(self.actualPath()+"?"+newquerystring,html)
                   
     def nextLink_old(self,html):      def nextLink_old(self,html):
         """prev link"""          """prev link"""
Line 541  class ZSQLExtendFolder(Persistent, Impli Line 567  class ZSQLExtendFolder(Persistent, Impli
             queries.append("-offset=%i"%offsetnew)              queries.append("-offset=%i"%offsetnew)
             newquerystring=string.join(queries,"&")              newquerystring=string.join(queries,"&")
                   
         return "<a href='%s'>%s</a>"%(self.REQUEST['URL0']+"?"+newquerystring,html)          return "<a href='%s'>%s</a>"%(self.actualPath()+"?"+newquerystring,html)
                   
           
 manage_addZSQLExtendFolderForm=DTMLFile('ZSQLExtendFolderAdd', globals())  manage_addZSQLExtendFolderForm=DTMLFile('ZSQLExtendFolderAdd', globals())

Removed from v.1.5  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>