Changeset 415:b93a2e5d5506 in documentViewer


Ignore:
Timestamp:
Dec 23, 2010, 4:12:23 PM (14 years ago)
Author:
casties
Branch:
default
Message:

new getInfoFromPage to read multiple parameters at once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MpdlXmlTextServer.py

    r414 r415  
    121121    def getNumTextPages (self, docinfo=None):
    122122        """get list of pages from fulltext (texts without images) and put in docinfo"""
     123        logging.debug("getNumTextPages")
    123124        docpath = docinfo['textURLPath']
    124125        selfurl = self.absolute_url()   
     
    138139    def getTocEntries (self, docinfo=None):
    139140        """ number of text entries"""
    140         docpath = docinfo['textURLPath']
    141         selfurl = self.absolute_url()
    142         if 'tocEntries' in docinfo:
    143             # allredy there
    144             return docinfo['tocEntries']
    145         if (docpath!=None):
    146             text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath']))
    147             dom =Parse(text)
    148             pagedivs = dom.xpath("//div[@class='countTocEntries']")
    149             #logging.debug ("pagedivs=%s"%(pagedivs))
    150             docinfo['tocEntries'] = getTextFromNode(pagedivs[0])
    151             #tc = int (originalPage)
    152             return docinfo['tocEntries']
     141        self.getInfoFromPage(docinfo)
     142        return docinfo['tocEntries']
    153143           
    154144    def getFigureEntries (self, docinfo=None):
    155145        """ number of figure entries"""
    156         docpath = docinfo['textURLPath']
    157         selfurl = self.absolute_url()
    158         if 'figureEntries' in docinfo:
    159             # allredy there
    160             return docinfo['figureEntries']
    161         if (docpath!=None):   
    162             text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath']))
    163             dom = Parse(text)
    164             pagedivs = dom.xpath("//div[@class='countFigureEntries']")
    165             #logging.debug ("pagedivs=%s"%(pagedivs))
    166             docinfo['figureEntries'] = getTextFromNode(pagedivs[0])
    167             #tc = int (docinfo['figureEntries'])
    168             return docinfo['figureEntries']
     146        self.getInfoFromPage(docinfo)
     147        return docinfo['figureEntries']
    169148                       
    170149    def getGisPlaces(self, docinfo=None, pageinfo=None):
     
    231210    def getAllPlaces (self, docinfo=None):
    232211        """Show all Places if no places than 0"""
    233         docpath = docinfo['textURLPath']
    234         selfurl = self.absolute_url()
     212        self.getInfoFromPage(docinfo)
     213        return docinfo['allPlaces']
     214
     215    def getInfoFromPage(self, docinfo=None):
     216        """ extract diverse info from page-fragment"""
     217        docpath = docinfo['textURLPath']
    235218        if 'allPlaces' in docinfo:
    236219            # allredy there
    237             return docinfo['allPlaces']
    238        
    239         text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath']))
    240         dom =Parse(text)
    241         pagedivs = dom.xpath("//div[@class='countPlaces']")
    242         logging.debug ("pagedivs=%s"%(pagedivs))
    243         if len(pagedivs)>0:
     220            return docinfo
     221       
     222        if (docpath is not None):   
     223            text = self.getServerData("page-fragment.xql","document=%s"%(docinfo['textURLPath']))
     224            dom = Parse(text)
     225            # figureEntries
     226            pagedivs = dom.xpath("//div[@class='countFigureEntries']")
     227            docinfo['figureEntries'] = getTextFromNode(pagedivs[0])
     228            # tocEntries
     229            pagedivs = dom.xpath("//div[@class='countTocEntries']")
     230            docinfo['tocEntries'] = getTextFromNode(pagedivs[0])
     231            # allPlaces
     232            pagedivs = dom.xpath("//div[@class='countPlaces']")
    244233            docinfo['allPlaces']= getTextFromNode(pagedivs[0])
    245             #logging.debug ("docinfo['allPlaces']=%s"%(docinfo['allPlaces']))
    246             return docinfo['allPlaces']
     234
     235        return docinfo
     236                       
    247237           
    248238    def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization="reg", highlightQuery=None, sn=None, optionToggle=None):
Note: See TracChangeset for help on using the changeset viewer.