Diff for /documentViewer/documentViewer.py between versions 1.10.2.1 and 1.17

version 1.10.2.1, 2006/06/13 14:57:46 version 1.17, 2006/07/26 12:23:55
Line 7  from Globals import package_home Line 7  from Globals import package_home
   
 from Ft.Xml.Domlette import NonvalidatingReader  from Ft.Xml.Domlette import NonvalidatingReader
 from Ft.Xml.Domlette import PrettyPrint, Print  from Ft.Xml.Domlette import PrettyPrint, Print
 from Ft.Xml import EMPTY_NAMESPACE  from Ft.Xml import EMPTY_NAMESPACE, Parse
   
 import Ft.Xml.XPath  import Ft.Xml.XPath
   
Line 142  class documentViewer(Folder): Line 142  class documentViewer(Folder):
     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)
         if access is None:          zLOG.LOG("documentViewer (accessOK)", zLOG.INFO, "access type %s"%access)
             # no information - no access           if access is not None and access == 'free':
             #TODO: check              zLOG.LOG("documentViewer (accessOK)", zLOG.INFO, "access is free")
             return True              return True
         elif access == 'free':          elif access is None or access in self.authgroups:
             return True  
         elif access in self.authgroups:  
             # only local access -- only logged in users              # only local access -- only logged in users
             user = getSecurityManager().getUser()              user = getSecurityManager().getUser()
             if user is not None:              if user is not None:
Line 163  class documentViewer(Folder): Line 161  class documentViewer(Folder):
                                   
     def getDirinfoFromDigilib(self,path,docinfo=None):      def getDirinfoFromDigilib(self,path,docinfo=None):
         """gibt param von dlInfo aus"""          """gibt param von dlInfo aus"""
           num_retries = 3
         if docinfo is None:          if docinfo is None:
             docinfo = {}              docinfo = {}
                           
         imageUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path          infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path
           
         zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo from %s"%(imageUrl))          zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo from %s"%(infoUrl))
                   
         for cnt in (1,2,3):          for cnt in range(num_retries):
             try:              try:
                 dom = NonvalidatingReader.parseUri(imageUrl)                  # dom = NonvalidatingReader.parseUri(imageUrl)
                   txt=urllib.urlopen(infoUrl).read()
                   dom = Parse(txt)
                 break                  break
             except:              except:
                 zLOG.LOG("documentViewer (getdirinfofromdigilib)", zLOG.ERROR, "error reading %s (try %d)"%(imageUrl,cnt))                  zLOG.LOG("documentViewer (getdirinfofromdigilib)", zLOG.ERROR, "error reading %s (try %d)"%(infoUrl,cnt))
         else:          else:
             raise IOError("Unable to get dir-info from %s"%(imageUrl))              raise IOError("Unable to get dir-info from %s"%(infoUrl))
                   
         sizes=dom.xpath("//dir/size")          sizes=dom.xpath("//dir/size")
         zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%sizes)          zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%sizes)
Line 198  class documentViewer(Folder): Line 199  class documentViewer(Folder):
         if url.startswith("http://"):          if url.startswith("http://"):
             # real URL              # real URL
             metaUrl = url              metaUrl = url
             try:  
                 dom = NonvalidatingReader.parseUri(url)  
             except:  
                 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])  
                 raise IOError("Unable to read index.meta from %s"%(url))  
         else:          else:
             # online path              # online path
             server=self.digilibBaseUrl+"/servlet/Texter?fn="              server=self.digilibBaseUrl+"/servlet/Texter?fn="
             metaUrl=server+url              metaUrl=server+url.replace("/mpiwg/online","")
             if not metaUrl.endswith("index.meta"):              if not metaUrl.endswith("index.meta"):
                 metaUrl += "/index.meta"                  metaUrl += "/index.meta"
                   
         for n in range(num_retries):          for cnt in range(num_retries):
             try:              try:
                 dom = NonvalidatingReader.parseUri(metaUrl)                  # patch dirk encoding fehler treten dann nicht mehr auf
                 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,metaUrl)                  # dom = NonvalidatingReader.parseUri(metaUrl)
                   txt=urllib.urlopen(metaUrl).read()
                   dom = Parse(txt)
                 break                  break
             except:              except:
                 zLOG.LOG("ERROR documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])                  zLOG.LOG("ERROR documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])
Line 283  class documentViewer(Folder): Line 281  class documentViewer(Folder):
        if dom is None:         if dom is None:
            dom = self.getIndexMeta(url)             dom = self.getIndexMeta(url)
                 
          archivePath = None
          archiveName = None
   
        archiveNames=dom.xpath("//resource/name")         archiveNames=dom.xpath("//resource/name")
        if archiveNames and (len(archiveNames)>0):         if archiveNames and (len(archiveNames)>0):
            archiveName=getTextFromNode(archiveNames[0])             archiveName=getTextFromNode(archiveNames[0])
          else:
              zLOG.LOG("documentViewer (getdocinfofromtexttool)", zLOG.WARNING,"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 293  class documentViewer(Folder): Line 296  class documentViewer(Folder):
            # clean up archive path             # clean up archive path
            if archivePath[0] != '/':             if archivePath[0] != '/':
                archivePath = '/' + archivePath                 archivePath = '/' + archivePath
            if not archivePath.endswith(archiveName):             if archiveName and (not archivePath.endswith(archiveName)):
                archivePath += "/" + archiveName                 archivePath += "/" + archiveName
        else:         else:
            archivePath=None             # try to get archive-path from url
              zLOG.LOG("documentViewer (getdocinfofromtexttool)", zLOG.WARNING,"resource/archive-path missing in: %s"%(url))
              if (not url.startswith('http')):
                  archivePath = url.replace('index.meta', '')
                  
          if archivePath is None:
              # we balk without archive-path
              raise IOError("Missing archive-path (for text-tool) in %s"%(url))
                 
        imageDirs=dom.xpath("//texttool/image")         imageDirs=dom.xpath("//texttool/image")
        if imageDirs and (len(imageDirs)>0):         if imageDirs and (len(imageDirs)>0):

Removed from v.1.10.2.1  
changed lines
  Added in v.1.17


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