changeset 70:0049d64aa464

filepath introduced
author dwinter
date Tue, 04 Nov 2008 20:51:35 +0100
parents 3b3c7cadd013
children 6412c45dff58
files documentViewer.py
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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))