changeset 496:f83ffab77502 metalify-1

last version from HEAD new zogilib version
author casties
date Fri, 18 Jun 2010 21:41:28 +0200
parents ede0c93de798
children
files MpdlXmlTextServer.py documentViewer.py
diffstat 2 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MpdlXmlTextServer.py	Thu Jun 17 19:35:24 2010 +0200
+++ b/MpdlXmlTextServer.py	Fri Jun 18 21:41:28 2010 +0200
@@ -6,6 +6,7 @@
 
 import sys
 import logging
+import urllib
 import documentViewer
 from documentViewer import getTextFromNode, serializeNode
 
@@ -121,7 +122,7 @@
                 return serializeNode(pagenode)      
         return "no text here"   
                        
-    def getNumPages(self,docinfo=None):
+    def getNumPages(self, docinfo):
         """get list of pages from fulltext and put in docinfo"""
         if 'numPages' in docinfo:
             # already there
@@ -216,19 +217,19 @@
 
     def getTranslate(self, query=None, language=None):
         """translate into another languages"""
-        data = self.getServerData("lt/lex.xql","document=&language="+str(language)+"&query="+url_quote(str(query)))
+        data = self.getServerData("lt/lex.xql","document=&language="+str(language)+"&query="+urllib.quote(query))
         #pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lex.xql","document=&language="+str(language)+"&query="+url_quote(str(query)))
         return data
     
     def getLemma(self, lemma=None, language=None):
         """simular words lemma """
-        data = self.getServerData("lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(lemma)))
+        data = self.getServerData("lt/lemma.xql","document=&language="+str(language)+"&lemma="+urllib.quote(lemma))
         #pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(lemma)))
         return data
     
     def getLemmaNew(self, query=None, language=None):
         """simular words lemma """
-        data = self.getServerData("lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(query)))
+        data = self.getServerData("lt/lemma.xql","document=&language="+str(language)+"&lemma="+urllib.quote(query))
         #pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(query)))
         return data
 
@@ -328,4 +329,4 @@
         RESPONSE.redirect('manage_main')
 
 
-    
\ No newline at end of file
+    
--- a/documentViewer.py	Thu Jun 17 19:35:24 2010 +0200
+++ b/documentViewer.py	Fri Jun 18 21:41:28 2010 +0200
@@ -7,7 +7,7 @@
 from Globals import package_home
 
 from Ft.Xml import EMPTY_NAMESPACE, Parse
-from Ft.Xml.Domlette import PrettyPrint, Print
+import Ft.Xml.Domlette
 import os.path
 import sys
 import urllib
@@ -43,7 +43,7 @@
 def serializeNode(node, encoding='utf-8'):
     """returns a string containing node as XML"""
     buf = cStringIO.StringIO()
-    Print(node, stream=buf, encoding=encoding)
+    Ft.Xml.Domlette.Print(node, stream=buf, encoding=encoding)
     s = buf.getvalue()
     buf.close()
     return s
@@ -172,9 +172,9 @@
         """get search"""
         return self.template.fulltextclient.getSearch(**args)
 
-    def getNumPages(self, **args):
+    def getNumPages(self, docinfo):
         """get numpages"""
-        return self.template.fulltextclient.getNumPages(**args)
+        return self.template.fulltextclient.getNumPages(docinfo)
 
     def getTranslate(self, **args):
         """get translate"""
@@ -266,8 +266,8 @@
         ret=""
         if mk is None:
             return ""
-    	if type(mk) is not ListType:
-    		mk=[mk]
+        if not isinstance(mk, list):
+            mk=[mk]
         for m in mk:
             ret+="mk=%s"%m
         return ret
@@ -305,7 +305,8 @@
                 params["url"] = getParentDir(params["url"])
                 
         # quote values and assemble into query string
-        ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
+        #ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
+        ps = urllib.urlencode(params)
         url=self.REQUEST['URL1']+"?"+ps
         return url
 
@@ -587,7 +588,7 @@
             docinfo['textURLPath'] = textUrl
             if not docinfo['imagePath']:
                 # text-only, no page images
-                docinfo = self.getNumPages(docinfo) #im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht    
+                docinfo = self.getNumPages(docinfo)
          
         presentationUrls = dom.xpath("//texttool/presentation")
         docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom)   # get info von bib tag