changeset 509:9d05befdd462 elementtree

try to get characterNormalization in search result working.
author casties
date Mon, 27 Feb 2012 21:57:18 +0100
parents d5a47f82e755
children 4fb35343d2e7
files MpdlXmlTextServer.py documentViewer.py zpt/viewer_text.zpt
diffstat 3 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MpdlXmlTextServer.py	Mon Feb 27 21:26:52 2012 +0100
+++ b/MpdlXmlTextServer.py	Mon Feb 27 21:57:18 2012 +0100
@@ -270,7 +270,7 @@
         return None
     
 
-    def getSearchResults(self, mode, query=None, docinfo=None):
+    def getSearchResults(self, mode, query=None, pageinfo=None, docinfo=None):
         """loads list of search results and stores XML in docinfo"""
         logging.debug("getSearchResults mode=%s query=%s"%(mode, query))
         if mode == "none":
@@ -281,16 +281,15 @@
             return docinfo
         
         docpath = docinfo['textURLPath']
-        # we need to set a result set size
-        pagesize = 1000
-        pn = 1
+        
         # fetch full results
         params = {'document': docpath,
                   'mode': 'text',
                   'queryType': mode,
                   'query': query,
                   'queryResultPageSize': 1000,
-                  'queryResultPN': 1}
+                  'queryResultPN': 1,
+                  'characterNormalization': pageinfo.get('characterNormalization', 'reg')}
         pagexml = self.getServerData("doc-query.xql",urllib.urlencode(params))
         #pagexml = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&s=%s&viewMode=%s&characterNormalization=%s&highlightElementPos=%s&highlightElement=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, s, viewMode,characterNormalization, highlightElementPos, highlightElement, urllib.quote(highlightQuery)))
         dom = ET.fromstring(pagexml)
@@ -321,7 +320,7 @@
         # check for cached TOC
         #TODO: cache only one search
         if not docinfo.has_key('resultXML_%s_%s'%(mode,query)):
-            self.getSearchResults(mode=mode, query=query, docinfo=docinfo)
+            self.getSearchResults(mode=mode, query=query, pageinfo=pageinfo, docinfo=docinfo)
             
         resultxml = docinfo.get('resultXML_%s_%s'%(mode,query), None)
         if not resultxml:
--- a/documentViewer.py	Mon Feb 27 21:26:52 2012 +0100
+++ b/documentViewer.py	Mon Feb 27 21:57:18 2012 +0100
@@ -732,16 +732,12 @@
                 
         # TODO: do we need this here?
         pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg')
-        pageinfo['query'] = self.REQUEST.get('query','') 
-        pageinfo['queryType'] = self.REQUEST.get('queryType','')
-        pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
-        pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
         pageinfo['tocPageSize'] = getInt(self.REQUEST.get('tocPageSize', 30))
-        pageinfo['queryPageSize'] = getInt(self.REQUEST.get('queryPageSize', 10))
+        pageinfo['resultPageSize'] = getInt(self.REQUEST.get('resultPageSize', 10))
         pageinfo['tocPN'] = getInt(self.REQUEST.get('tocPN', '1'))
-        pageinfo['searchPN'] = getInt(self.REQUEST.get('searchPN','1'))
+        pageinfo['resultPN'] = getInt(self.REQUEST.get('resultPN','1'))
         
-        # limit tocPN
+        # limit tocPN TODO: do we need this?
         if 'tocSize_%s'%tocMode in docinfo:
             tocSize = docinfo['tocSize_%s'%tocMode]
             tocPageSize = pageinfo['tocPageSize']
--- a/zpt/viewer_text.zpt	Mon Feb 27 21:26:52 2012 +0100
+++ b/zpt/viewer_text.zpt	Mon Feb 27 21:57:18 2012 +0100
@@ -68,6 +68,7 @@
         <div class="options">
           <h4>Text display</h4>
           <pre tal:content="python:repr(viewLayers)" />
+          <pre tal:content="python:repr(viewLayer)" />
           <form tal:attributes="action viewerUrl" class="autosubmit">
             <input type="hidden"
               tal:define="params python:here.getParams(params={'viewLayer':None,'viewMode':None})"
@@ -181,7 +182,7 @@
           <form tal:attributes="action viewerUrl" class="autosubmit"
             tal:define="norm python:pageinfo.get('characterNormalization','regPlusNorm');">
             <input type="hidden"
-              tal:define="params python:here.getParams('characterNormalization',None)"
+              tal:define="params python:here.getParams(params={'characterNormalization':None, 'viewLayer':viewLayer})"
               tal:repeat="param params"
               tal:attributes="name param; value python:params[param]" />
             <ul>