--- documentViewer/documentViewer.py 2008/06/25 10:47:58 1.32 +++ documentViewer/documentViewer.py 2008/11/04 19:51:35 1.33 @@ -332,7 +332,7 @@ class documentViewer(Folder): return dom - def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None): + def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): """gets authorization info from the index.meta file at path or given by dom""" logger("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path)) @@ -342,7 +342,9 @@ class documentViewer(Folder): docinfo = {} if dom is None: - dom = self.getIndexMeta(getParentDir(path)) + for x in range(cut+1): + path=getParentDir(path) + dom = self.getIndexMeta(path) acctype = dom.xpath("//access-conditions/access/@type") if acctype and (len(acctype)>0): @@ -354,7 +356,7 @@ class documentViewer(Folder): return docinfo - def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None): + def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): """gets bibliographical info from the index.meta file at path or given by dom""" logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) @@ -362,7 +364,9 @@ class documentViewer(Folder): docinfo = {} if dom is None: - dom = self.getIndexMeta(getParentDir(path)) + for x in range(cut+1): + path=getParentDir(path) + dom = self.getIndexMeta(path) # put in all raw bib fields as dict "bib" bib = dom.xpath("//bib/*") @@ -508,7 +512,7 @@ class documentViewer(Folder): pass return docinfo - def getDocinfoFromImagePath(self,path,docinfo=None): + 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.""" logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path)) if docinfo is None: @@ -519,8 +523,8 @@ class documentViewer(Folder): imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path docinfo['imageURL'] = imageUrl - docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo) - docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo) + docinfo = self.getBibinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) + docinfo = self.getAuthinfoFromIndexMeta(path,docinfo=docinfo,cut=cut) return docinfo @@ -540,6 +544,8 @@ class documentViewer(Folder): docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) elif mode=="imagepath": docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) + elif mode=="filepath": + docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) else: logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!") raise ValueError("Unknown mode %s"%(mode))