Mercurial > hg > documentViewer
changeset 435:94baa8dbc7e8
*** empty log message ***
author | abukhman |
---|---|
date | Tue, 01 Mar 2011 15:53:15 +0100 |
parents | 44ccb7bd0938 |
children | 0baf4e761be7 |
files | MpdlXmlTextServer.py documentViewer.py |
diffstat | 2 files changed, 8 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/MpdlXmlTextServer.py Thu Feb 24 14:55:28 2011 +0100 +++ b/MpdlXmlTextServer.py Tue Mar 01 15:53:15 2011 +0100 @@ -129,7 +129,6 @@ l.setAttributeNS(None, 'onClick', 'popupWin.focus();') return serializeNode(pagenode) return "no text here" - def getGisPlaces(self, docinfo=None, pageinfo=None): """ Show all Gis Places of whole Page""" @@ -201,21 +200,17 @@ pagexml = self.getServerData("page-fragment.xql",textParam) dom = Parse(pagexml) - #original Pages pagedivs = dom.xpath("//div[@class='pageNumberOrig']") if pagedivs == dom.xpath("//div[@class='pageNumberOrig']"): if len(pagedivs)>0: docinfo['pageNumberOrig']= getTextFromNode(pagedivs[0]) - #logging.debug("ORIGINAL PAGES: %s"%(docinfo['pageNumberOrig'])) #original Pages Norm pagedivs = dom.xpath("//div[@class='pageNumberOrigNorm']") if pagedivs == dom.xpath("//div[@class='pageNumberOrigNorm']"): if len(pagedivs)>0: docinfo['pageNumberOrigNorm']= getTextFromNode(pagedivs[0]) - #logging.debug("ORIGINAL PAGES: %s"%(docinfo['pageNumberOrigNorm'])) - #figureEntries pagedivs = dom.xpath("//div[@class='countFigureEntries']") @@ -226,14 +221,12 @@ if s=='0': try: docinfo['countFigureEntries'] = int(s) - #logging.debug("FIGURE ENTRIES: %s"%(s)) except: docinfo['countFigureEntries'] = 0 else: s1 = int(s)/30+1 try: docinfo['countFigureEntries'] = int(s1) - #logging.debug("FIGURE ENTRIES: %s"%(s1)) except: docinfo['countFigureEntries'] = 0 @@ -245,7 +238,6 @@ s = getTextFromNode(pagedivs[0]) try: docinfo['countPlaces'] = int(s) - #logging.debug("PLACES HERE: %s"%(s)) except: docinfo['countPlaces'] = 0 @@ -258,14 +250,12 @@ if s=='0': try: docinfo['countTocEntries'] = int(s) - #logging.debug("TEXT ENTRIES: %s"%(s)) except: docinfo['countTocEntries'] = 0 else: s1 = int(s)/30+1 try: docinfo['countTocEntries'] = int(s1) - #logging.debug("TEXT ENTRIES: %s"%(s1)) except: docinfo['countTocEntries'] = 0 @@ -301,7 +291,6 @@ # plain text mode if mode == "text": # first div contains text - #mode = viewMode pagedivs = dom.xpath("/div") if len(pagedivs) > 0: pagenode = pagedivs[0] @@ -406,14 +395,11 @@ pagedom = Parse(pagexml) numdivs = pagedom.xpath("//div[@class='queryResultHits']") tocSearch = int(getTextFromNode(numdivs[0])) - #logging.debug("documentViewer (gettoc) tocSearch: %s"%(tocSearch)) tc=int((tocSearch/10)+1) - #logging.debug("documentViewer (gettoc) tc: %s"%(tc)) return tc def getToc(self, mode="text", docinfo=None): """loads table of contents and stores in docinfo""" - #logging.debug("documentViewer (gettoc) mode: %s"%(mode)) if mode == "none": return docinfo if 'tocSize_%s'%mode in docinfo: @@ -465,8 +451,6 @@ data = self.getServerData("doc-query.xql","document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s&characterNormalization=regPlusNorm&optionToggle=1"%(docpath,queryType, pagesize, pn)) page = data.replace('page-fragment.xql?document=%s'%str(path),'%s?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&optionToggle=1'%(selfurl,url, viewMode, tocMode, tocPN)) text = page.replace('mode=image','mode=texttool') - #logging.debug("documentViewer (characterNormalization) characterNormalization: %s"%(characterNormalization)) - #logging.debug("TEXT %s"%(text)) return text def manage_changeMpdlXmlTextServer(self,title="",serverUrl="http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40,RESPONSE=None):
--- a/documentViewer.py Thu Feb 24 14:55:28 2011 +0100 +++ b/documentViewer.py Tue Mar 01 15:53:15 2011 +0100 @@ -43,12 +43,14 @@ rc = rc + node.data return rc -def serializeNode(node, encoding='utf-8'): +def serializeNode(node, encoding="utf-8"): """returns a string containing node as XML""" - buf = cStringIO.StringIO() - Ft.Xml.Domlette.Print(node, stream=buf, encoding=encoding) - s = buf.getvalue() - buf.close() + stream = cStringIO.StringIO() + logging.debug("BUF: %s"%(stream)) + Ft.Xml.Domlette.PrettyPrint(node, stream=stream, encoding=encoding) + s = stream.getvalue() + logging.debug("BUF: %s"%(s)) + stream.close() return s def browserCheck(self): @@ -161,8 +163,6 @@ raise IOError("ERROR fetching HTTP data from %s: %s"%(url,errmsg)) #return None - - ## ## documentViewer class ## @@ -898,13 +898,10 @@ pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','') pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10') - pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') - + pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') toc = int (pageinfo['tocPN']) pageinfo['textPages'] =int (toc) - - if 'tocSize_%s'%tocMode in docinfo: tocSize = int(docinfo['tocSize_%s'%tocMode]) tocPageSize = int(pageinfo['tocPageSize'])