Changeset 167:7e2b97941a66 in documentViewer
- Timestamp:
- Aug 24, 2010, 12:43:24 PM (15 years ago)
- Branch:
- default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
MpdlXmlTextServer.py
r166 r167 43 43 docpath = docinfo['textURLPath'] 44 44 url = docinfo['url'] 45 #logging.debug("documentViewer (gettoc) docpath: %s"%(docpath))46 #logging.debug("documentViewer (gettoc) url: %s"%(url))45 logging.debug("documentViewer (gettoc) docpath: %s"%(docpath)) 46 logging.debug("documentViewer (gettoc) url: %s"%(url)) 47 47 pagesize = pageinfo['queryPageSize'] 48 48 pn = pageinfo['searchPN'] … … 254 254 tocSearch = int(getTextFromNode(numdivs[0])) 255 255 tc=int((tocSearch/10)+1) 256 #logging.debug("documentViewer (gettoc) tc: %s"%(tc))256 logging.debug("documentViewer (gettoc) tc: %s"%(tc)) 257 257 return tc 258 258 259 259 def getToc(self, mode="text", docinfo=None): 260 260 """loads table of contents and stores in docinfo""" 261 #logging.debug("documentViewer (gettoc) mode: %s"%(mode))261 logging.debug("documentViewer (gettoc) mode: %s"%(mode)) 262 262 if mode == "none": 263 263 return docinfo … … 303 303 selfurl = self.absolute_url() 304 304 viewMode= pageinfo['viewMode'] 305 characterNormalization =pageinfo ['characterNormalization']305 characterNormalization =pageinfo ['characterNormalization'] 306 306 tocMode = pageinfo['tocMode'] 307 307 tocPN = pageinfo['tocPN'] 308 308 309 data = self.getServerData("doc-query.xql","document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s "%(docpath,queryType, pagesize, pn))310 page = data.replace('page-fragment.xql?document=%s'%str(path),'%s?url=%s&viewMode=%s&tocMode=%s&tocPN=%s &characterNormalization=%s'%(selfurl,url, viewMode, tocMode, tocPN,characterNormalization))309 data = self.getServerData("doc-query.xql","document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s&characterNormalization=%s"%(docpath,queryType, pagesize, pn,characterNormalization)) 310 page = data.replace('page-fragment.xql?document=%s'%str(path),'%s?url=%s&viewMode=%s&tocMode=%s&tocPN=%s'%(selfurl,url, viewMode, tocMode, tocPN)) 311 311 text = page.replace('mode=image','mode=texttool') 312 312 logging.debug("documentViewer (characterNormalization) characterNormalization: %s"%(characterNormalization)) -
documentViewer.py
r166 r167 69 69 for cnt in range(num_tries): 70 70 try: 71 #logging.debug("getHttpData(#%s %ss) url=%s"%(cnt+1,timeout,url))71 logging.debug("getHttpData(#%s %ss) url=%s"%(cnt+1,timeout,url)) 72 72 if sys.version_info < (2, 6): 73 73 # set timeout on socket -- ugly :-( … … 80 80 break 81 81 except urllib2.HTTPError, e: 82 #logging.error("getHttpData: HTTP error(%s): %s"%(e.code,e))82 logging.error("getHttpData: HTTP error(%s): %s"%(e.code,e)) 83 83 errmsg = str(e) 84 84 # stop trying 85 85 break 86 86 except urllib2.URLError, e: 87 #logging.error("getHttpData: URLLIB error(%s): %s"%(e.reason,e))87 logging.error("getHttpData: URLLIB error(%s): %s"%(e.reason,e)) 88 88 errmsg = str(e) 89 89 # stop trying … … 204 204 205 205 ''' 206 #logging.debug("HHHHHHHHHHHHHH:load the rss")207 #logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))206 logging.debug("HHHHHHHHHHHHHH:load the rss") 207 logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) 208 208 209 209 if not hasattr(self, 'template'): … … 238 238 ''' 239 239 240 #logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))240 logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) 241 241 242 242 if not hasattr(self, 'template'): … … 324 324 325 325 # quote values and assemble into query string 326 #logging.debug("XYXXXXX: %s"%repr(params.items()))326 logging.debug("XYXXXXX: %s"%repr(params.items())) 327 327 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) 328 328 url=self.REQUEST['URL1']+"?"+ps … … 343 343 """returns if access to the resource is granted""" 344 344 access = docinfo.get('accessType', None) 345 #logging.debug("documentViewer (accessOK) access type %s"%access)345 logging.debug("documentViewer (accessOK) access type %s"%access) 346 346 if access is not None and access == 'free': 347 #logging.debug("documentViewer (accessOK) access is free")347 logging.debug("documentViewer (accessOK) access is free") 348 348 return True 349 349 elif access is None or access in self.authgroups: 350 350 # only local access -- only logged in users 351 351 user = getSecurityManager().getUser() 352 #logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr()))352 logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr())) 353 353 if user is not None: 354 354 #print "user: ", user … … 357 357 return False 358 358 359 #logging.error("documentViewer (accessOK) unknown access type %s"%access)359 logging.error("documentViewer (accessOK) unknown access type %s"%access) 360 360 return False 361 361 … … 372 372 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path 373 373 374 #logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl))374 logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl)) 375 375 376 376 txt = getHttpData(infoUrl) … … 380 380 dom = Parse(txt) 381 381 sizes=dom.xpath("//dir/size") 382 #logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)382 logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes) 383 383 384 384 if sizes: … … 406 406 metaUrl += "/index.meta" 407 407 408 #logging.debug("(getIndexMeta): METAURL: %s"%metaUrl)408 logging.debug("(getIndexMeta): METAURL: %s"%metaUrl) 409 409 txt=getHttpData(metaUrl) 410 410 if txt is None: … … 436 436 def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): 437 437 """gets authorization info from the index.meta file at path or given by dom""" 438 #logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path))438 logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path)) 439 439 440 440 access = None … … 460 460 def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): 461 461 """gets bibliographical info from the index.meta file at path or given by dom""" 462 #logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path))462 logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) 463 463 464 464 if docinfo is None: … … 470 470 dom = self.getIndexMeta(path) 471 471 472 #logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))472 logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) 473 473 # put in all raw bib fields as dict "bib" 474 474 bib = dom.xpath("//bib/*") … … 501 501 docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) 502 502 except: pass 503 #logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)503 logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) 504 504 try: 505 505 docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) … … 512 512 def getDocinfoFromTextTool(self, url, dom=None, docinfo=None): 513 513 """parse texttool tag in index meta""" 514 #logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url))514 logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url)) 515 515 if docinfo is None: 516 516 docinfo = {} … … 539 539 else: 540 540 # try to get archive-path from url 541 #logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url))541 logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url)) 542 542 if (not url.startswith('http')): 543 543 archivePath = url.replace('index.meta', '') … … 633 633 def getDocinfoFromImagePath(self,path,docinfo=None,cut=0): 634 634 """path ist the path to the images it assumes that the index.meta file is one level higher.""" 635 #logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path))635 logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path)) 636 636 if docinfo is None: 637 637 docinfo = {} … … 643 643 for x in range(cut): 644 644 path=getParentDir(path) 645 #logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path)645 logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path) 646 646 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path 647 647 docinfo['imageURL'] = imageUrl … … 655 655 def getDocinfo(self, mode, url): 656 656 """returns docinfo depending on mode""" 657 #logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url))657 logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url)) 658 658 # look for cached docinfo in session 659 659 if self.REQUEST.SESSION.has_key('docinfo'): … … 661 661 # check if its still current 662 662 if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url: 663 #logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo)663 logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo) 664 664 return docinfo 665 665 # new docinfo … … 672 672 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) 673 673 else: 674 #logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)674 logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode) 675 675 raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) 676 676 677 #logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)677 logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo) 678 678 self.REQUEST.SESSION['docinfo'] = docinfo 679 679 return docinfo … … 702 702 pageinfo['viewMode'] = viewMode 703 703 pageinfo['tocMode'] = tocMode 704 pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization',' ')704 pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization',' ') 705 705 pageinfo['query'] = self.REQUEST.get('query',' ') 706 706 pageinfo['queryType'] = self.REQUEST.get('queryType',' ') … … 768 768 ob = getattr(self, id) 769 769 txt=file(os.path.join(package_home(globals()),'zpt/viewer_main.zpt'),'r').read() 770 #logging.info("txt %s:"%txt)770 logging.info("txt %s:"%txt) 771 771 ob.pt_edit(txt,"text/html") 772 772 if title:
Note: See TracChangeset
for help on using the changeset viewer.