changeset 174:5780092e4989

*** empty log message ***
author dwinter
date Wed, 01 Sep 2010 15:25:38 +0200
parents 9fa61da63e5e
children d1c13a6ba20d
files documentViewer.py
diffstat 1 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Tue Aug 24 16:10:13 2010 +0200
+++ b/documentViewer.py	Wed Sep 01 15:25:38 2010 +0200
@@ -16,6 +16,7 @@
 import math
 import urlparse 
 import cStringIO
+import re
 
 def logger(txt,method,txt2):
     """logging"""
@@ -390,10 +391,18 @@
                         
         return docinfo
     
-            
-    def getIndexMeta(self, url):
-        """returns dom of index.meta document at url"""
-        dom = None
+    def getIndexMetaPath(self,url):
+        """gib nur den Pfad zurueck"""
+        regexp = re.compile(r".*(experimental|permanent)/(.*)")
+        regpath = regexp.match(url)
+        if (regpath==None):
+            return ""
+                     
+        return ("/mpiwg/online/"+regpath.group(1)+"/"+regpath.group(2))
+     
+    def getIndexMetaUrl(self,url):
+        """returns utr  of index.meta document at url"""
+      
         metaUrl = None
         if url.startswith("http://"):
             # real URL
@@ -404,8 +413,15 @@
             metaUrl=server+url.replace("/mpiwg/online","")
             if not metaUrl.endswith("index.meta"):
                 metaUrl += "/index.meta"
+        
+        return metaUrl
+    
+    def getDomFromIndexMeta(self, url):
+        """get dom from index meta"""
+        dom = None
+        metaUrl = self.getIndexMetaUrl(url)
                 
-        logging.debug("(getIndexMeta): METAURL: %s"%metaUrl)
+        logging.debug("(getDomFromIndexMeta): METAURL: %s"%metaUrl)
         txt=getHttpData(metaUrl)
         if txt is None:
             raise IOError("Unable to read index meta from %s"%(url))
@@ -445,7 +461,7 @@
         if dom is None:
             for x in range(cut):
                 path=getParentDir(path)
-            dom = self.getIndexMeta(path)
+            dom = self.getDomFromIndexMeta(path)
        
         acctype = dom.xpath("//access-conditions/access/@type")
         if acctype and (len(acctype)>0):
@@ -467,7 +483,9 @@
         if dom is None:
             for x in range(cut):
                 path=getParentDir(path)
-            dom = self.getIndexMeta(path)
+            dom = self.getDomFromIndexMeta(path)
+        
+        docinfo['indexMetaPath']=self.getIndexMetaPath(path);
         
         logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
         # put in all raw bib fields as dict "bib"
@@ -489,6 +507,8 @@
         bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC)
         docinfo['bib_type'] = bibtype
         bibmap=metaData.generateMappingForType(bibtype)
+        logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap))
+        logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype))
         # if there is no mapping bibmap is empty (mapping sometimes has empty fields)
         if len(bibmap) > 0 and len(bibmap['author'][0]) > 0:
             try:
@@ -517,7 +537,7 @@
         if docinfo.get('lang', None) is None:
             docinfo['lang'] = '' # default keine Sprache gesetzt
         if dom is None:
-            dom = self.getIndexMeta(url)
+            dom = self.getDomFromIndexMeta(url)
         
         archivePath = None
         archiveName = None