--- documentViewer/documentViewer.py 2006/06/13 14:57:46 1.10.2.1 +++ documentViewer/documentViewer.py 2006/07/06 16:01:42 1.14 @@ -7,7 +7,7 @@ from Globals import package_home from Ft.Xml.Domlette import NonvalidatingReader from Ft.Xml.Domlette import PrettyPrint, Print -from Ft.Xml import EMPTY_NAMESPACE +from Ft.Xml import EMPTY_NAMESPACE, Parse import Ft.Xml.XPath @@ -142,11 +142,13 @@ 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 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 +165,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) @@ -198,22 +203,19 @@ class documentViewer(Folder): if url.startswith("http://"): # real 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: # 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: - dom = NonvalidatingReader.parseUri(metaUrl) - zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,metaUrl) + # 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]) @@ -517,4 +519,4 @@ def manage_addDocumentViewerTemplate(sel return '' - \ No newline at end of file +