Diff for /documentViewer/documentViewer.py between versions 1.69.2.1 and 1.69.2.2

version 1.69.2.1, 2010/06/14 10:49:48 version 1.69.2.2, 2010/06/16 16:38:17
Line 266  class documentViewer(Folder, extraFuncti Line 266  class documentViewer(Folder, extraFuncti
                 params[param] = str(val)                  params[param] = str(val)
                                   
         # quote values and assemble into query string          # quote values and assemble into query string
         logging.info("XYXXXXX: %s"%repr(params.items()))          logging.debug("XYXXXXX: %s"%repr(params.items()))
         ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])          ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
         url=self.REQUEST['URL1']+"?"+ps          url=self.REQUEST['URL1']+"?"+ps
         return url          return url
Line 285  class documentViewer(Folder, extraFuncti Line 285  class documentViewer(Folder, extraFuncti
     def isAccessible(self, docinfo):      def isAccessible(self, docinfo):
         """returns if access to the resource is granted"""          """returns if access to the resource is granted"""
         access = docinfo.get('accessType', None)          access = docinfo.get('accessType', None)
         logger("documentViewer (accessOK)", logging.INFO, "access type %s"%access)          logging.debug("documentViewer (accessOK) access type %s"%access)
         if access is not None and access == 'free':          if access is not None and access == 'free':
             logger("documentViewer (accessOK)", logging.INFO, "access is free")              logging.debug("documentViewer (accessOK) access is free")
             return True              return True
         elif access is None or access in self.authgroups:          elif access is None or access in self.authgroups:
             # only local access -- only logged in users              # only local access -- only logged in users
Line 298  class documentViewer(Folder, extraFuncti Line 298  class documentViewer(Folder, extraFuncti
             else:              else:
                 return False                  return False
                   
         logger("documentViewer (accessOK)", logging.INFO, "unknown access type %s"%access)          logging.debug("documentViewer (accessOK) unknown access type %s"%access)
         return False          return False
           
                                   
Line 314  class documentViewer(Folder, extraFuncti Line 314  class documentViewer(Folder, extraFuncti
                 
         infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path          infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path
           
         logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl))          logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl))
                   
         for cnt in range(num_retries):          for cnt in range(num_retries):
             try:              try:
Line 323  class documentViewer(Folder, extraFuncti Line 323  class documentViewer(Folder, extraFuncti
                 dom = Parse(txt)                  dom = Parse(txt)
                 break                  break
             except:              except:
                 logger("documentViewer (getdirinfofromdigilib)", logging.ERROR, "error reading %s (try %d)"%(infoUrl,cnt))                  logging.error("documentViewer (getdirinfofromdigilib) error reading %s (try %d)"%(infoUrl,cnt))
         else:          else:
             raise IOError("Unable to get dir-info from %s"%(infoUrl))              raise IOError("Unable to get dir-info from %s"%(infoUrl))
                   
         sizes=dom.xpath("//dir/size")          sizes=dom.xpath("//dir/size")
         logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo:size"%sizes)          logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)
                   
         if sizes:          if sizes:
             docinfo['numPages'] = int(getTextFromNode(sizes[0]))              docinfo['numPages'] = int(getTextFromNode(sizes[0]))
Line 363  class documentViewer(Folder, extraFuncti Line 363  class documentViewer(Folder, extraFuncti
                 dom = Parse(txt)                  dom = Parse(txt)
                 break                  break
             except:              except:
                 logger("ERROR documentViewer (getIndexMeta)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])                  logging.error("ERROR documentViewer (getIndexMeta) %s (%s)"%sys.exc_info()[0:2])
                                   
         if dom is None:          if dom is None:
             raise IOError("Unable to read index meta from %s"%(url))              raise IOError("Unable to read index meta from %s"%(url))
Line 391  class documentViewer(Folder, extraFuncti Line 391  class documentViewer(Folder, extraFuncti
                 dom = Parse(txt)                  dom = Parse(txt)
                 break                  break
             except:              except:
                 logger("ERROR documentViewer (getPresentationInfoXML)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])                  logging.error("ERROR documentViewer (getPresentationInfoXML) %s (%s)"%sys.exc_info()[0:2])
                                   
         if dom is None:          if dom is None:
             raise IOError("Unable to read infoXMLfrom %s"%(url))              raise IOError("Unable to read infoXMLfrom %s"%(url))
Line 401  class documentViewer(Folder, extraFuncti Line 401  class documentViewer(Folder, extraFuncti
                   
     def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):      def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
         """gets authorization info from the index.meta file at path or given by dom"""          """gets authorization info from the index.meta file at path or given by dom"""
         logger("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path))          logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path))
                   
         access = None          access = None
                   
Line 477  class documentViewer(Folder, extraFuncti Line 477  class documentViewer(Folder, extraFuncti
           
     def getDocinfoFromTextTool(self, url, dom=None, docinfo=None):      def getDocinfoFromTextTool(self, url, dom=None, docinfo=None):
         """parse texttool tag in index meta"""          """parse texttool tag in index meta"""
         logger("documentViewer (getdocinfofromtexttool)", logging.INFO, "url: %s" % (url))          logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url))
         if docinfo is None:          if docinfo is None:
            docinfo = {}             docinfo = {}
         if docinfo.get('lang', None) is None:          if docinfo.get('lang', None) is None:
Line 492  class documentViewer(Folder, extraFuncti Line 492  class documentViewer(Folder, extraFuncti
         if archiveNames and (len(archiveNames) > 0):          if archiveNames and (len(archiveNames) > 0):
             archiveName = getTextFromNode(archiveNames[0])              archiveName = getTextFromNode(archiveNames[0])
         else:          else:
             logger("documentViewer (getdocinfofromtexttool)", logging.WARNING, "resource/name missing in: %s" % (url))              logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url))
                   
         archivePaths = dom.xpath("//resource/archive-path")          archivePaths = dom.xpath("//resource/archive-path")
         if archivePaths and (len(archivePaths) > 0):          if archivePaths and (len(archivePaths) > 0):
Line 504  class documentViewer(Folder, extraFuncti Line 504  class documentViewer(Folder, extraFuncti
                 archivePath += "/" + archiveName                  archivePath += "/" + archiveName
         else:          else:
             # try to get archive-path from url              # try to get archive-path from url
             logger("documentViewer (getdocinfofromtexttool)", logging.WARNING, "resource/archive-path missing in: %s" % (url))              logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url))
             if (not url.startswith('http')):              if (not url.startswith('http')):
                 archivePath = url.replace('index.meta', '')                  archivePath = url.replace('index.meta', '')
                                   
Line 596  class documentViewer(Folder, extraFuncti Line 596  class documentViewer(Folder, extraFuncti
           
     def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):      def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):
         """path ist the path to the images it assumes that the index.meta file is one level higher."""          """path ist the path to the images it assumes that the index.meta file is one level higher."""
         logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path))          logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path))
         if docinfo is None:          if docinfo is None:
             docinfo = {}              docinfo = {}
         path=path.replace("/mpiwg/online","")          path=path.replace("/mpiwg/online","")
Line 606  class documentViewer(Folder, extraFuncti Line 606  class documentViewer(Folder, extraFuncti
         pathorig=path          pathorig=path
         for x in range(cut):                 for x in range(cut):       
                 path=getParentDir(path)                  path=getParentDir(path)
         logging.error("PATH:"+path)          logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path)
         imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path          imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path
         docinfo['imageURL'] = imageUrl          docinfo['imageURL'] = imageUrl
                   
Line 618  class documentViewer(Folder, extraFuncti Line 618  class documentViewer(Folder, extraFuncti
           
     def getDocinfo(self, mode, url):      def getDocinfo(self, mode, url):
         """returns docinfo depending on mode"""          """returns docinfo depending on mode"""
         logger("documentViewer (getdocinfo)", logging.INFO,"mode: %s, url: %s"%(mode,url))          logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url))
         # look for cached docinfo in session          # look for cached docinfo in session
         if self.REQUEST.SESSION.has_key('docinfo'):          if self.REQUEST.SESSION.has_key('docinfo'):
             docinfo = self.REQUEST.SESSION['docinfo']              docinfo = self.REQUEST.SESSION['docinfo']
             # check if its still current              # check if its still current
             if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url:              if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url:
                 logger("documentViewer (getdocinfo)", logging.INFO,"docinfo in session: %s"%docinfo)                  logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo)
                 return docinfo                  return docinfo
         # new docinfo          # new docinfo
         docinfo = {'mode': mode, 'url': url}          docinfo = {'mode': mode, 'url': url}
Line 635  class documentViewer(Folder, extraFuncti Line 635  class documentViewer(Folder, extraFuncti
         elif mode=="filepath":          elif mode=="filepath":
             docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)              docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)
         else:          else:
             logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!")              logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)
             raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode))              raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode))
                                                   
         logger("documentViewer (getdocinfo)", logging.INFO,"docinfo: %s"%docinfo)          logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
         self.REQUEST.SESSION['docinfo'] = docinfo          self.REQUEST.SESSION['docinfo'] = docinfo
         return docinfo          return docinfo
                                 

Removed from v.1.69.2.1  
changed lines
  Added in v.1.69.2.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>