--- ZSQLExtend/ZSQLExtend.py 2004/10/19 11:24:12 1.41
+++ ZSQLExtend/ZSQLExtend.py 2004/10/25 13:13:48 1.45
@@ -13,6 +13,24 @@ from Products.PageTemplates.PageTemplate
from Products.ZSQLMethods.SQL import SQLConnectionIDs
import Shared.DC.ZRDB.DA
+def analyseIntSearch(word):
+ #analyse integer searches
+
+ splitted=word.split("-")
+
+ if len(splitted)==1:
+ return "="+splitted[0]
+
+ if splitted[0]=="":
+ return "< "+splitted[1]
+
+ if splitted[1]=='':
+ return "> "+splitted[0]
+ else:
+ return "BETWEEN "+splitted[0]+" AND "+splitted[1]
+
+
+
def sql_quote(v):
# quote dictionary
quote_dict = {"\'": "''", "\\": "\\\\"}
@@ -40,10 +58,10 @@ class ZSQLExtendFolder(Folder,Persistent
"""suche relative haufigkeiten"""
ret={}
allRecords=len(self.ZSQLSimpleSearch(statement + " where "+wherePart))
- print statement + " where "+wherePart
+
for oneclass in classes:
ret[oneclass]=len(self.ZSQLSimpleSearch(statement + " where ("+wherePart+") and "+ relStatement%oneclass))
- print statement + " where ("+wherePart+") and "+ relStatement%oneclass
+
return (ret,allRecords)
def content_html(self):
@@ -268,14 +286,14 @@ class ZSQLExtendFolder(Folder,Persistent
qs=[]
-
+
#print "INLINE:",query
return self.ZSQLSimpleSearch(query)
def ZSQLSimpleSearch(self,query=None):
""" returrn SQLSearch"""
- #print query
+ #print "hi",query
if not query:
query=self.query
if getattr(self,'_v_search',None):
@@ -660,7 +678,19 @@ class ZSQLExtendFolder(Folder,Persistent
tmps.append(name+" LIKE "+sql_quote("%"+word+"%"))
tmp=string.join(tmps,' AND ')
-
+
+ elif op=="numerical":
+ term=analyseIntSearch(value)
+ tmp=(name+" "+term)
+ elif op=="grep":
+ tmp=(name+" ~* "+sql_quote(value))
+ elif op=="one":
+ tmps=[]
+ for word in value.split(" "):
+ tmps.append(name+" LIKE "+sql_quote("%"+word+"%"))
+
+ tmp=string.join(tmps,' OR ')
+
op="ct"
if (not tableExt) or (namealt.split('.')[0]==tableExt):
@@ -786,6 +816,7 @@ class ZSQLExtendFolder(Folder,Persistent
def nextLink(self,html,storename="foundCount"):
"""nextLink"""
+
try:
limit=self.REQUEST.SESSION[storename]['rangeSize']
if int(limit)==0 :
@@ -832,12 +863,13 @@ class ZSQLExtendFolder(Folder,Persistent
newquery.append(query)
newquerystring=string.join(newquery,"&")
-
- return "%s"%(self.actualPath()+"?"+newquerystring,html)
+ return "%s"%(self.REQUEST['URL']+"?"+newquerystring,html)
+
def prevLink(self,html,storename="foundCount"):
"""prev link"""
+
try:
limit=self.REQUEST.SESSION[storename]['rangeSize']
if int(limit)==0 :
@@ -889,7 +921,7 @@ class ZSQLExtendFolder(Folder,Persistent
newquerystring=string.join(newquery,"&")
- return "%s"%(self.actualPath()+"?"+newquerystring,html)
+ return "%s"%(self.REQUEST['URL']+"?"+newquerystring,html)