# HG changeset patch # User dwinter # Date 1225828295 -3600 # Node ID 0049d64aa4648e34b0a61531b484b79a67d5592d # Parent 3b3c7cadd013a30f51243337b04df1d8c3dc6d0d filepath introduced diff -r 3b3c7cadd013 -r 0049d64aa464 documentViewer.py --- a/documentViewer.py Tue Jul 22 16:33:27 2008 +0200 +++ b/documentViewer.py Tue Nov 04 20:51:35 2008 +0100 @@ -332,7 +332,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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))