changeset 13:5f48f956ffa3

more resistant to empty data
author casties
date Fri, 29 Jul 2011 20:35:10 +0200
parents 7f0e2b656e5c
children 281d223aa361
files MetaData.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MetaData.py	Fri Jul 29 18:28:06 2011 +0200
+++ b/MetaData.py	Fri Jul 29 20:35:10 2011 +0200
@@ -43,7 +43,8 @@
             
         self.shortDescription =shortDescription #label fuer link auf add page
         self.description=description #description of the method for link page
-        self.fieldList=fields.split(",")[0:]
+        if fields:
+            self.fieldList=fields.split(",")[0:]
         #self.metaDataServerUrl="" # muss mit change metadata gesetzt werden
     
     
@@ -85,6 +86,9 @@
         
     def getData(self, path=None, dom=None, normalizeNames=True, recursive=0):
         """returns dict with attributes and child elements from corresponding tag"""
+        if path is None and dom is None:
+            return None
+        
         data = {}
         attr = {}
         elem = self.getSubDom(path=path, dom=dom)
@@ -208,9 +212,13 @@
                gets data from server or dom or pre-parsed data."""
             logging.debug("getFormatted(template=%s)"%(template))
             
-            # get contents of bib tag
+            # get contents of tag
             if data is None:
                 data = self.getData(path=path, dom=dom)
+                if data is None:
+                    # no data
+                    logging.error("getFormatted: no data for template: %s"%(template))
+                    return ""
 
             type = data.get('@type', '')
            
@@ -330,9 +338,9 @@
     pt=PageTemplateFile('zpt/addMetadataForm', globals()).__of__(self)
     return pt()
 
-def manage_addMetaData(self,id,shortDescription,description,fields,RESPONSE=None):
+def manage_addMetaData(self,id,title=None,shortDescription=None,description=None,fields=None,RESPONSE=None):
     """a metadata objekt"""
-    newObj = MetaData(id,shortDescription,description,fields)
+    newObj = MetaData(id,title=title,shortDescription=shortDescription,description=description,fields=fields)
     self.Destination()._setObject(id,newObj)
     if RESPONSE is not None:
         RESPONSE.redirect('manage_main')