Diff for /documentViewer/documentViewer.py between versions 1.46 and 1.47

version 1.46, 2010/04/21 13:50:59 version 1.47, 2010/04/27 12:58:31
Line 10  from Ft.Xml.Domlette import Nonvalidatin Line 10  from Ft.Xml.Domlette import Nonvalidatin
 from Ft.Xml.Domlette import PrettyPrint, Print  from Ft.Xml.Domlette import PrettyPrint, Print
 from Ft.Xml import EMPTY_NAMESPACE, Parse  from Ft.Xml import EMPTY_NAMESPACE, Parse
   
   from xml.dom.minidom import parse, parseString
   
   
   
 import Ft.Xml.XPath  import Ft.Xml.XPath
 import cStringIO  import cStringIO
Line 184  class documentViewer(Folder): Line 187  class documentViewer(Folder):
             self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary"              self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary"
                           
         docinfo = self.getDocinfo(mode=mode,url=url)          docinfo = self.getDocinfo(mode=mode,url=url)
         pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo,viewMode=viewMode,tocMode=tocMode)          
           
         if tocMode != "thumbs":          if tocMode != "thumbs":
             # get table of contents              # get table of contents
             docinfo = self.getToc(mode=tocMode, docinfo=docinfo)              docinfo = self.getToc(mode=tocMode, docinfo=docinfo)
   
           pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo,viewMode=viewMode,tocMode=tocMode)
           
         if viewMode=="auto": # automodus gewaehlt          if viewMode=="auto": # automodus gewaehlt
             if docinfo.get("textURL",''): #texturl gesetzt und textViewer konfiguriert              if docinfo.get("textURL",''): #texturl gesetzt und textViewer konfiguriert
                 viewMode="text"                  viewMode="text"
Line 656  class documentViewer(Folder): Line 662  class documentViewer(Folder):
         pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')          pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
         pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '20')          pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '20')
         pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')          pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')
           #if 'tocSize_%s'%tocMode in docinfo:
               # cached toc
             # pageinfo['tocPN'] = min (int (docinfo['tocSize_%s'%tocMode])/int(pageinfo['tocPageSize']),int(pageinfo['tocPN']))
                  
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')          pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
         pageinfo['sn'] =self.REQUEST.get('sn','1')          pageinfo['sn'] =self.REQUEST.get('sn','1')
   
Line 674  class documentViewer(Folder): Line 684  class documentViewer(Folder):
         tocPN = pageinfo['tocPN']          tocPN = pageinfo['tocPN']
         pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn) ,outputUnicode=False)                     pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn) ,outputUnicode=False)           
         pagedom = Parse(pagexml)          pagedom = Parse(pagexml)
         #pagedivs = pagedom.xpath("//div[@class='queryResultPage']")          pagedivs = pagedom.xpath("//div[@class='queryResultPage']")
           
         selfurl = self.absolute_url()          selfurl = self.absolute_url()
           
         page = pagexml.replace('page-fragment.xql?document=/echo/la/Benedetti_1585.xml','%s?url=/mpiwg/online/permanent/library/163127KK&viewMode=%s&tocMode=%s&tocPN=%s&query=%s&queryType=%s'%(selfurl, viewMode, tocMode, tocPN, query, queryType))          page = pagexml.replace('page-fragment.xql?document=/echo/la/Benedetti_1585.xml','%s?url=/mpiwg/online/permanent/library/163127KK&viewMode=%s&tocMode=%s&tocPN=%s&query=%s&queryType=%s'%(selfurl, viewMode, tocMode, tocPN, query, queryType))
         text =page.replace('mode=text','mode=texttool')          text =page.replace('mode=text','mode=texttool')
         return text          href = text.replace('lt/lex.xql','%s/template/head_main_voc'%selfurl)
           lemma= href.replace('lt/lemma.xql','%s/template/head_main_lemma'%selfurl)
           #logging.debug("documentViewer (gettoc) lemma: %s"%(lemma))
           
           return lemma
                          
       
         #if len(pagedivs) > 0:          #if len(pagedivs) > 0:
         #    pagenode = pagedom[0]          #    pagenode = pagedom[0]
         #    return serializeNode(pagenode)          #    return serializeNode(pagenode)
Line 756  class documentViewer(Folder): Line 774  class documentViewer(Folder):
         pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lex.xql","query=%s&language=%s"%(query,language),outputUnicode=False)          pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lex.xql","query=%s&language=%s"%(query,language),outputUnicode=False)
         return pagexml          return pagexml
           
     def getLemma(self):      def getLemma(self, lemma=None, language=None):
         """lemma"""          """lemma"""
         pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","query=%s&language=%s"%(query,language),outputUnicode=False)          pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","lemma=%s&language=%s"%(lemma,language),outputUnicode=False)
         return pagexml          return pagexml
   
       def getQuery (self,  docinfo=None, pageinfo=None, query=None, queryType=None, pn=1):
            """number of"""
            docpath = docinfo['textURLPath'] 
            pagesize = pageinfo['queryPageSize']
            pn = pageinfo['searchPN']
            query =pageinfo['query']
            queryType =pageinfo['queryType']
   
            tocSearch = 0
            tocDiv = None
            pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath, 'text', queryType, query, pagesize, pn) ,outputUnicode=False)
            
            pagedom = Parse(pagexml)
            numdivs = pagedom.xpath("//div[@class='queryResultHits']")
            tocSearch = int(getTextFromNode(numdivs[0]))
            tc=int((tocSearch/20)+1)
            logging.debug("documentViewer (gettoc) tc: %s"%(tc))
            return tc
   
     def getToc(self, mode="text", docinfo=None):      def getToc(self, mode="text", docinfo=None):
         """loads table of contents and stores in docinfo"""          """loads table of contents and stores in docinfo"""
         logging.debug("documentViewer (gettoc) mode: %s"%(mode))          logging.debug("documentViewer (gettoc) mode: %s"%(mode))
         if 'tocSize_%s'%mode in docinfo:          if 'tocSize_%s'%mode in docinfo:
             # cached toc              # cached toc
             return docinfo              return docinfo
           
         docpath = docinfo['textURLPath']          docpath = docinfo['textURLPath']
         # we need to set a result set size          # we need to set a result set size
         pagesize = 1000          pagesize = 1000

Removed from v.1.46  
changed lines
  Added in v.1.47


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