--- documentViewer/documentViewer.py 2006/06/13 15:21:47 1.12 +++ documentViewer/documentViewer.py 2006/07/18 16:59:57 1.16 @@ -142,11 +142,12 @@ class documentViewer(Folder): def isAccessible(self, docinfo): """returns if access to the resource is granted""" access = docinfo.get('accessType', None) + zLOG.LOG("documentViewer (accessOK)", zLOG.INFO, "access type %s"%access) if access is None: # no information - no access - #TODO: check - return True + return False elif access == 'free': + zLOG.LOG("documentViewer (accessOK)", zLOG.INFO, "access is free") return True elif access in self.authgroups: # only local access -- only logged in users @@ -163,21 +164,24 @@ class documentViewer(Folder): def getDirinfoFromDigilib(self,path,docinfo=None): """gibt param von dlInfo aus""" + num_retries = 3 if docinfo is None: 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: - dom = NonvalidatingReader.parseUri(imageUrl) + # dom = NonvalidatingReader.parseUri(imageUrl) + txt=urllib.urlopen(infoUrl).read() + dom = Parse(txt) break 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: - 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") zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%sizes) @@ -201,16 +205,17 @@ class documentViewer(Folder): else: # online path server=self.digilibBaseUrl+"/servlet/Texter?fn=" - metaUrl=server+url + metaUrl=server+url.replace("/mpiwg/online","") if not metaUrl.endswith("index.meta"): metaUrl += "/index.meta" - for n in range(num_retries): + for cnt in range(num_retries): try: # patch dirk encoding fehler treten dann nicht mehr auf # dom = NonvalidatingReader.parseUri(metaUrl) txt=urllib.urlopen(metaUrl).read() dom = Parse(txt) + break except: zLOG.LOG("ERROR documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) @@ -279,9 +284,14 @@ class documentViewer(Folder): if dom is None: dom = self.getIndexMeta(url) + archivePath = None + archiveName = None + archiveNames=dom.xpath("//resource/name") if archiveNames and (len(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") if archivePaths and (len(archivePaths)>0): @@ -289,10 +299,17 @@ class documentViewer(Folder): # clean up archive path if archivePath[0] != '/': archivePath = '/' + archivePath - if not archivePath.endswith(archiveName): + if archiveName and (not archivePath.endswith(archiveName)): archivePath += "/" + archiveName 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") if imageDirs and (len(imageDirs)>0): @@ -513,4 +530,4 @@ def manage_addDocumentViewerTemplate(sel return '' - \ No newline at end of file +