--- documentViewer/MpdlXmlTextServer.py 2010/12/23 16:12:23 1.218 +++ documentViewer/MpdlXmlTextServer.py 2010/12/23 17:13:01 1.221 @@ -138,12 +138,13 @@ class MpdlXmlTextServer(SimpleItem): def getTocEntries (self, docinfo=None): """ number of text entries""" - self.getInfoFromPage(docinfo) + docinfo = self.getInfoFromPage(docinfo) + logging.debug("gettocentries: docinfo=%s"%docinfo) return docinfo['tocEntries'] def getFigureEntries (self, docinfo=None): """ number of figure entries""" - self.getInfoFromPage(docinfo) + docinfo = self.getInfoFromPage(docinfo) return docinfo['figureEntries'] def getGisPlaces(self, docinfo=None, pageinfo=None): @@ -209,7 +210,7 @@ class MpdlXmlTextServer(SimpleItem): def getAllPlaces (self, docinfo=None): """Show all Places if no places than 0""" - self.getInfoFromPage(docinfo) + docinfo = self.getInfoFromPage(docinfo) return docinfo['allPlaces'] def getInfoFromPage(self, docinfo=None): @@ -224,13 +225,31 @@ class MpdlXmlTextServer(SimpleItem): dom = Parse(text) # figureEntries pagedivs = dom.xpath("//div[@class='countFigureEntries']") - docinfo['figureEntries'] = getTextFromNode(pagedivs[0]) + s = getTextFromNode(pagedivs[0]) + try: + docinfo['figureEntries'] = int(s) + except: + docinfo['figureEntries'] = 0 # tocEntries pagedivs = dom.xpath("//div[@class='countTocEntries']") - docinfo['tocEntries'] = getTextFromNode(pagedivs[0]) + s = getTextFromNode(pagedivs[0]) + try: + docinfo['tocEntries'] = int(s) + except: + docinfo['tocEntries'] = 0 # allPlaces pagedivs = dom.xpath("//div[@class='countPlaces']") - docinfo['allPlaces']= getTextFromNode(pagedivs[0]) + s = getTextFromNode(pagedivs[0]) + try: + docinfo['allPlaces'] = int(s) + except: + docinfo['allPlaces'] = 0 + + else: + # no full text -- init to 0 + docinfo['figureEntries'] = 0 + docinfo['tocEntries'] = 0 + docinfo['allPlaces'] = 0 return docinfo