# HG changeset patch # User casties # Date 1311964510 -7200 # Node ID 5f48f956ffa320f027fd17775d5d54997d16f832 # Parent 7f0e2b656e5c961c91c749ac71bdfb27f6405a20 more resistant to empty data diff -r 7f0e2b656e5c -r 5f48f956ffa3 MetaData.py --- 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')