changeset 27:a0d273542509

better DRI handling.
author casties
date Wed, 15 Aug 2012 17:07:37 +0200
parents a19575be96e8
children 40508e672841
files MetaData.py MetaDataFolder.py
diffstat 2 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MetaData.py	Mon Jul 30 19:43:23 2012 +0200
+++ b/MetaData.py	Wed Aug 15 17:07:37 2012 +0200
@@ -289,8 +289,6 @@
             """returns string with document data formatted according to template.
                gets data from server or dom or pre-parsed data."""
             logging.debug("getFormatted(template=%s)"%(template))
-            logging.debug(self.absolute_url())
-            logging.debug(self.__dict__)
                         
             # get contents of tag
             if data is None:
@@ -303,7 +301,6 @@
             type = data.get('@type', '')
            
             # get template
-          
             tp=getattr(self,"%s_%s"%(template, normalizeFieldName(type)), None)
             
             if tp is None:
@@ -320,8 +317,7 @@
             else:
                 fields = {}
             
-            logging.debug("XXXX")    
-            logging.debug(tp)    
+            #logging.debug(tp)    
             return tp(mdmap=fields, md=data)
 
 
--- a/MetaDataFolder.py	Mon Jul 30 19:43:23 2012 +0200
+++ b/MetaDataFolder.py	Wed Aug 15 17:07:37 2012 +0200
@@ -143,7 +143,7 @@
         if mdObj is not None:
             return mdObj.getData(path=path, dom=dom, recursive=recursive, all=all, allText=allText)
         else:
-            logging.error("getXmlPathData: MetaData element at '%s' not found!"%xmlpath)
+            logging.error("getXmlPathData: MetaData object for '%s' not found!"%xmlpath)
             return None
 
     def getXmlPathFormatted(self, xmlpath, template, path=None, dom=None, data=None, allFields=False, recursive=0, all=False, allText=False):
@@ -170,7 +170,7 @@
             return fmt
         
         else:
-            logging.error("getXmlPathFormatted: MetaData element at '%s' not found!"%xmlpath)
+            logging.error("getXmlPathFormatted: MetaData object for '%s' not found!"%xmlpath)
             return ''
 
     def getResourceData(self, path=None, dom=None):
@@ -212,19 +212,24 @@
     def getDRI(self, path=None, dom=None, type="escidoc"):
         """returns the DRI of the document"""
         dris = self.getXmlPathData('resource/meta/dri', path=path, dom=dom, all=True)
-        logging.debug("getDRI: dris=%s"%repr(dris))
+        #logging.debug("getDRI: dris=%s"%repr(dris))
         if dris is None:
             return None
         
         for dri in dris:
-            logging.debug("getDRI: dri=%s"%dri)
+            #logging.debug("getDRI: dri=%s"%dri)
+            if type is None:
+                # no type -- take the first one
+                return dri.get('@text', None)
+            
+            # use element with matching @type
             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"""