Changeset 4:e9085ba2bb51 in documentViewer for documentViewer.py
- Timestamp:
- Jun 16, 2010, 4:38:17 PM (14 years ago)
- Branch:
- modularisierung
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r2 r4 267 267 268 268 # quote values and assemble into query string 269 logging. info("XYXXXXX: %s"%repr(params.items()))269 logging.debug("XYXXXXX: %s"%repr(params.items())) 270 270 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) 271 271 url=self.REQUEST['URL1']+"?"+ps … … 286 286 """returns if access to the resource is granted""" 287 287 access = docinfo.get('accessType', None) 288 logg er("documentViewer (accessOK)", logging.INFO, "access type %s"%access)288 logging.debug("documentViewer (accessOK) access type %s"%access) 289 289 if access is not None and access == 'free': 290 logg er("documentViewer (accessOK)", logging.INFO, "access is free")290 logging.debug("documentViewer (accessOK) access is free") 291 291 return True 292 292 elif access is None or access in self.authgroups: … … 299 299 return False 300 300 301 logg er("documentViewer (accessOK)", logging.INFO, "unknown access type %s"%access)301 logging.debug("documentViewer (accessOK) unknown access type %s"%access) 302 302 return False 303 303 … … 315 315 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path 316 316 317 logg er("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl))317 logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl)) 318 318 319 319 for cnt in range(num_retries): … … 324 324 break 325 325 except: 326 logg er("documentViewer (getdirinfofromdigilib)", logging.ERROR, "error reading %s (try %d)"%(infoUrl,cnt))326 logging.error("documentViewer (getdirinfofromdigilib) error reading %s (try %d)"%(infoUrl,cnt)) 327 327 else: 328 328 raise IOError("Unable to get dir-info from %s"%(infoUrl)) 329 329 330 330 sizes=dom.xpath("//dir/size") 331 logg er("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo:size"%sizes)331 logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes) 332 332 333 333 if sizes: … … 364 364 break 365 365 except: 366 logg er("ERROR documentViewer (getIndexMeta)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])366 logging.error("ERROR documentViewer (getIndexMeta) %s (%s)"%sys.exc_info()[0:2]) 367 367 368 368 if dom is None: … … 392 392 break 393 393 except: 394 logg er("ERROR documentViewer (getPresentationInfoXML)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])394 logging.error("ERROR documentViewer (getPresentationInfoXML) %s (%s)"%sys.exc_info()[0:2]) 395 395 396 396 if dom is None: … … 402 402 def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): 403 403 """gets authorization info from the index.meta file at path or given by dom""" 404 logg er("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path))404 logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path)) 405 405 406 406 access = None … … 478 478 def getDocinfoFromTextTool(self, url, dom=None, docinfo=None): 479 479 """parse texttool tag in index meta""" 480 logg er("documentViewer (getdocinfofromtexttool)", logging.INFO, "url: %s" % (url))480 logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url)) 481 481 if docinfo is None: 482 482 docinfo = {} … … 493 493 archiveName = getTextFromNode(archiveNames[0]) 494 494 else: 495 logg er("documentViewer (getdocinfofromtexttool)", logging.WARNING, "resource/name missing in: %s" % (url))495 logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url)) 496 496 497 497 archivePaths = dom.xpath("//resource/archive-path") … … 505 505 else: 506 506 # try to get archive-path from url 507 logg er("documentViewer (getdocinfofromtexttool)", logging.WARNING, "resource/archive-path missing in: %s" % (url))507 logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url)) 508 508 if (not url.startswith('http')): 509 509 archivePath = url.replace('index.meta', '') … … 597 597 def getDocinfoFromImagePath(self,path,docinfo=None,cut=0): 598 598 """path ist the path to the images it assumes that the index.meta file is one level higher.""" 599 logg er("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path))599 logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path)) 600 600 if docinfo is None: 601 601 docinfo = {} … … 607 607 for x in range(cut): 608 608 path=getParentDir(path) 609 logging. error("PATH:"+path)609 logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path) 610 610 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path 611 611 docinfo['imageURL'] = imageUrl … … 619 619 def getDocinfo(self, mode, url): 620 620 """returns docinfo depending on mode""" 621 logg er("documentViewer (getdocinfo)", logging.INFO,"mode: %s, url: %s"%(mode,url))621 logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url)) 622 622 # look for cached docinfo in session 623 623 if self.REQUEST.SESSION.has_key('docinfo'): … … 625 625 # check if its still current 626 626 if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url: 627 logg er("documentViewer (getdocinfo)", logging.INFO,"docinfo in session: %s"%docinfo)627 logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo) 628 628 return docinfo 629 629 # new docinfo … … 636 636 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) 637 637 else: 638 logg er("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!")638 logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode) 639 639 raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) 640 640 641 logg er("documentViewer (getdocinfo)", logging.INFO,"docinfo: %s"%docinfo)641 logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo) 642 642 self.REQUEST.SESSION['docinfo'] = docinfo 643 643 return docinfo
Note: See TracChangeset
for help on using the changeset viewer.