Diff for /ZSQLExtend/ZSQLExtend.py between versions 1.71 and 1.77

version 1.71, 2005/11/08 13:37:32 version 1.77, 2005/12/22 21:10:34
Line 67  class ZSQLExtendFolder(Folder,Persistent Line 67  class ZSQLExtendFolder(Folder,Persistent
     """Folder"""      """Folder"""
     meta_type="ZSQLExtendFolder"      meta_type="ZSQLExtendFolder"
           
       def ZSQLQuote(self,str):
           """quote str for sql"""
           return sql_quote(str)
       
       
     def importXMLFile(self,table,containerTagName,file,identify=None,RESPONSE=None):      def importXMLFile(self,table,containerTagName,file,identify=None,RESPONSE=None):
         #TODO: finish importXMLFile          #TODO: finish importXMLFile
         '''          '''
Line 98  class ZSQLExtendFolder(Folder,Persistent Line 103  class ZSQLExtendFolder(Folder,Persistent
         """erzeuge index aus feld"""          """erzeuge index aus feld"""
         index={}          index={}
         founds=self.ZSQLSimpleSearch("""SELECT %s,oid FROM %s LIMIT 2000"""%(field,table))          founds=self.ZSQLSimpleSearch("""SELECT %s,oid FROM %s LIMIT 2000"""%(field,table))
         print len(founds)  
         for found in founds:          for found in founds:
             tmp=getattr(found,field,None)              tmp=getattr(found,field,None)
             if tmp:              if tmp:
Line 202  class ZSQLExtendFolder(Folder,Persistent Line 207  class ZSQLExtendFolder(Folder,Persistent
     def formatAscii(self,str,url=None):      def formatAscii(self,str,url=None):
         """ersetze ascii umbrueche durch <br>"""          """ersetze ascii umbrueche durch <br>"""
         #url=None          #url=None
           str=str.rstrip().lstrip()
           
         if url and str:          if url and str:
                           
             retStr=""              retStr=""
Line 353  class ZSQLExtendFolder(Folder,Persistent Line 360  class ZSQLExtendFolder(Folder,Persistent
         if start:          if start:
         if start==' ':          if start==' ':
         start=''          start=''
               
                 if not startValue:                  if not startValue:
                     startValue=start                      startValue=start
                                           
Line 377  class ZSQLExtendFolder(Folder,Persistent Line 385  class ZSQLExtendFolder(Folder,Persistent
         qs=[]          qs=[]
         if storename:          if storename:
             """store"""              """store"""
               storename=storename
         else:          else:
             storename="foundCount"              storename="foundCount"
                           
Line 423  class ZSQLExtendFolder(Folder,Persistent Line 432  class ZSQLExtendFolder(Folder,Persistent
         return self.ZSQLSimpleSearch(query)          return self.ZSQLSimpleSearch(query)
           
           
       def ZSQLResetConnection(self):
           """reset the connectione"""
           try:
               self.getConnectionObj().manage_close_connection()
           except:
               zLOG.LOG("ZSQLResetConnection",zLOG.ERROR, '%s %s'%sys.exc_info()[:2])
           try:
               self.getConnectionObj().manage_open_connection()
           except:
               zLOG.LOG("ZSQLResetConnection",zLOG.ERROR, '%s %s'%sys.exc_info()[:2])
   
     def ZSQLSimpleSearch(self,query=None,max_rows=1000000):      def ZSQLSimpleSearch(self,query=None,max_rows=1000000):
         """simple search"""          """simple search"""
                   
         if not query:          if not query:
             query=self.query              query=self.query
                   
           
         if (hasattr(self,"_v_searchSQL") and (self._v_searchSQL == None)) or (not hasattr(self,"_v_searchSQL")):          if (hasattr(self,"_v_searchSQL") and (self._v_searchSQL == None)) or (not hasattr(self,"_v_searchSQL")):
                           
             self._v_searchSQL=Shared.DC.ZRDB.DA.DA("_v_searchSQL","_v_searchSQL",self.getConnectionObj().getId(),"var","<dtml-var var>")              self._v_searchSQL=Shared.DC.ZRDB.DA.DA("_v_searchSQL","_v_searchSQL",self.getConnectionObj().getId(),"var","<dtml-var var>")
                           
             self._v_searchSQL.max_rows_=max_rows              self._v_searchSQL.max_rows_=max_rows
             try:              try:
                   
                 return self._v_searchSQL.__call__(var=query)                  return self._v_searchSQL.__call__(var=query)
             except :              except :
   
                 if sys.exc_info()[0]=="Database Error":                  if sys.exc_info()[0]=="Database Error":
                     try:                      try:
                         self.getConnectionObj().manage_open_connection()                          self.getConnectionObj().manage_open_connection()
Line 445  class ZSQLExtendFolder(Folder,Persistent Line 466  class ZSQLExtendFolder(Folder,Persistent
                         zLOG.LOG("ZSQLSimpleSearch",zLOG.ERROR, '%s %s'%sys.exc_info()[:2])                          zLOG.LOG("ZSQLSimpleSearch",zLOG.ERROR, '%s %s'%sys.exc_info()[:2])
         else:          else:
             try:              try:
   
                 self._v_searchSQL.max_rows_=max_rows                  self._v_searchSQL.max_rows_=max_rows
                                   
                 return self._v_searchSQL.__call__(var=query)                  return self._v_searchSQL.__call__(var=query)
             except :              except :
   
                 if sys.exc_info()[0]=="Database Error":                  if sys.exc_info()[0]=="Database Error":
                     try:                      try:
                         self.getConnectionObj().manage_open_connection()                          self.getConnectionObj().manage_open_connection()
Line 575  class ZSQLExtendFolder(Folder,Persistent Line 598  class ZSQLExtendFolder(Folder,Persistent
             elif name=="-format":              elif name=="-format":
                 format=urllib.unquote(value)                  format=urllib.unquote(value)
             elif (not (name[0]=="-" or name[0]=="_")) and (not len(value)==0):              elif (not (name[0]=="-" or name[0]=="_")) and (not len(value)==0):
   
                 changeList.append("\""+name+"\"="+sql_quote(urllib.unquote(value)))                  changeList.append("\""+name+"\"="+sql_quote(urllib.unquote(value)))
                                   
         changeString=string.join(changeList,",")          changeString=string.join(changeList,",")
   
         queryString="UPDATE %s SET %s WHERE %s"%(table,changeString,identify)          queryString="UPDATE %s SET %s WHERE %s"%(table,changeString,identify)
                   
         self.ZSQLSimpleSearch(queryString)          self.ZSQLSimpleSearch(queryString)
Line 812  class ZSQLExtendFolder(Folder,Persistent Line 837  class ZSQLExtendFolder(Folder,Persistent
   
         #check for op           #check for op 
         splitted=qs.split(",")          splitted=qs.split(",")
         print splitted  
         if tableExt:          if tableExt:
             table=tableExt              table=tableExt
   
Line 914  class ZSQLExtendFolder(Folder,Persistent Line 939  class ZSQLExtendFolder(Folder,Persistent
                     op="ct"                      op="ct"
                 namealt=name                  namealt=name
                 name="LOWER("+punktsplit[1]+")"                   name="LOWER("+punktsplit[1]+")" 
                 print "XX",op     
                 if op=="ct":                  if op=="ct":
                     tmp=(name+" LIKE "+sql_quote("%"+value+"%"))                      tmp=(name+" LIKE "+sql_quote("%"+value+"%"))
                 elif op=="gt":                  elif op=="gt":
Line 948  class ZSQLExtendFolder(Folder,Persistent Line 973  class ZSQLExtendFolder(Folder,Persistent
   
                 op="all"                  op="all"
   
                 print punktsplit  
                 searchTmp="""%s in (select %s from %s where %s)"""%(punktsplit[3],punktsplit[2],punktsplit[0],tmp)                  searchTmp="""%s in (select %s from %s where %s)"""%(punktsplit[3],punktsplit[2],punktsplit[0],tmp)
                 print "got",searchTmp  
                 queryTemplate.append(searchTmp)                  queryTemplate.append(searchTmp)
                                   
             elif (not name[0]==iCT) and (not len(value)==0):              elif (not name[0]==iCT) and (not len(value)==0):
Line 1031  class ZSQLExtendFolder(Folder,Persistent Line 1056  class ZSQLExtendFolder(Folder,Persistent
         #print "QE",table          #print "QE",table
         #print (select,table,where,sort,maxstr,skip)          #print (select,table,where,sort,maxstr,skip)
         query="SELECT %s FROM %s %s %s %s %s"%(select,table,where,sort,maxstr,skip)          query="SELECT %s FROM %s %s %s %s %s"%(select,table,where,sort,maxstr,skip)
         print query  
         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 and (not NoQuery):          if storename and (not NoQuery):
   
             query2="SELECT count(*) FROM %s %s"%(table,where)              query2="SELECT count(*) FROM %s %s"%(table,where)
                           
             #print "QUERYSTRING:",self.REQUEST.SESSION[storename]['queryString2']              #print "QUERYSTRING:",self.REQUEST.SESSION[storename]['queryString2']
Line 1562  class ZSQLBibliography(Folder,ZSQLExtend Line 1588  class ZSQLBibliography(Folder,ZSQLExtend
         host_port = self.REQUEST['SERVER_PORT']          host_port = self.REQUEST['SERVER_PORT']
         fix_host = None          fix_host = None
         if http_host and http_host.rfind(host_port) == -1:          if http_host and http_host.rfind(host_port) == -1:
             print "HTTP_HOST needs fixing!"              #print "HTTP_HOST needs fixing!"
             fix_host = http_host + ":" + host_port              fix_host = http_host + ":" + host_port
                   
         ret="""<?xml version="1.0" ?>          ret="""<?xml version="1.0" ?>

Removed from v.1.71  
changed lines
  Added in v.1.77


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