Mercurial > hg > documentViewer
changeset 570:61d53ccbdd70
more resilience to server errors.
author | casties |
---|---|
date | Fri, 12 Oct 2012 16:01:41 +0200 |
parents | be21250420be |
children | f1906951be2a |
files | MpdlXmlTextServer.py MpiwgXmlTextServer.py zpt/viewer_text.zpt |
diffstat | 3 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/MpdlXmlTextServer.py Fri Oct 12 15:34:37 2012 +0200 +++ b/MpdlXmlTextServer.py Fri Oct 12 16:01:41 2012 +0200 @@ -118,7 +118,7 @@ # all info in tag <document> doc = dom.find("document") except Exception, e: - logging.error("getTextInfo: Error getting data: %s"%e) + logging.error("getTextInfo: Error reading doc info: %s"%e) return docinfo if doc is None: @@ -294,9 +294,14 @@ textParams['mode'] = textmode - # fetch the page - pagexml = self.getServerData("page-fragment.xql",urllib.urlencode(textParams)) - dom = ET.fromstring(pagexml) + try: + # fetch the page + pagexml = self.getServerData("page-fragment.xql",urllib.urlencode(textParams)) + dom = ET.fromstring(pagexml) + except Exception, e: + logging.error("getTextPage: Error reading page: %s"%e) + return None + # extract additional info self.processPageInfo(dom, docinfo, pageinfo) # page content is in <div class="pageContent">
--- a/MpiwgXmlTextServer.py Fri Oct 12 15:34:37 2012 +0200 +++ b/MpiwgXmlTextServer.py Fri Oct 12 16:01:41 2012 +0200 @@ -259,12 +259,12 @@ textParams['mode'] = 'untokenized' textParams['outputFormat'] = 'html' - # fetch the page - pagexml = self.getServerData("query/GetPage",urllib.urlencode(textParams)) try: + # fetch the page + pagexml = self.getServerData("query/GetPage",urllib.urlencode(textParams)) dom = ET.fromstring(pagexml) except Exception, e: - logging.error("Error parsing page: %s"%e) + logging.error("Error reading page: %s"%e) return None pagediv = None
--- a/zpt/viewer_text.zpt Fri Oct 12 15:34:37 2012 +0200 +++ b/zpt/viewer_text.zpt Fri Oct 12 16:01:41 2012 +0200 @@ -54,11 +54,11 @@ <div class="ruler top"> <metal:block metal:use-macro="here/template/common_template/macros/page_ruler" /> </div> - <div class="content text" tal:condition="textPage"> + <div class="content text"> <div class="pageHeaderTitle" tal:condition="exists:pageinfo/pageHeaderTitle" tal:content="structure pageinfo/pageHeaderTitle" /> <tal:block tal:condition="textPage" tal:replace="structure textPage"/> - <div class="emptyPage" tal:condition="not:textPage">[Empty page]</div> + <div class="emptyPage" tal:condition="not:textPage">[Error: no page]</div> </div> </div> <!-- end of col-main -->