diff MetaDataFolder.py @ 26:a19575be96e8

getDRI reshuffled, works on python 2.6. now.
author casties
date Mon, 30 Jul 2012 19:43:23 +0200
parents 64b703d1b8a4
children a0d273542509
line wrap: on
line diff
--- a/MetaDataFolder.py	Fri Jul 27 12:53:51 2012 +0200
+++ b/MetaDataFolder.py	Mon Jul 30 19:43:23 2012 +0200
@@ -130,7 +130,6 @@
     def getXmlPathObj(self, xmlpath):
         """returns object at xmlpath"""
         # make xmlpath relative for Zope
-        logging.debug("XMlPAth:"+xmlpath)
         if xmlpath[0] == '/':
             xmlpath = xmlpath[1:]
             
@@ -207,13 +206,25 @@
     def getContextData(self, path=None, dom=None, all=True):
         """returns contents of context tag as dict"""
         # information is two tags deep - recursive=1
-        
         return self.getXmlPathData('resource/meta/context', path=path, dom=dom,  all=all)
         
     
-    def getDRI(self,path=None,type="escidoc",dom=None):
+    def getDRI(self, path=None, dom=None, type="escidoc"):
         """returns the DRI of the document"""
-        return self.resource.meta.getDRI(path=path, dom=dom)
+        dris = self.getXmlPathData('resource/meta/dri', path=path, dom=dom, all=True)
+        logging.debug("getDRI: dris=%s"%repr(dris))
+        if dris is None:
+            return None
+        
+        for dri in dris:
+            logging.debug("getDRI: dri=%s"%dri)
+            att = dri.get('@attr', None)
+            if att is not None:
+                if (att.get('type', None) == type):
+                    return dri.get('@text', None)
+        
+        return None
+        #return self.resource.meta.getDRI(path=path, dom=dom, type=type)
     
     def getBibData(self, path=None, dom=None):
         """returns contents of bib tag as dict"""