diff MetaData.py @ 11:a29665fa9c62

more work for non-bib metadata
author casties
date Fri, 29 Jul 2011 14:45:13 +0200
parents eeaad777d3d7
children 7f0e2b656e5c
line wrap: on
line diff
--- a/MetaData.py	Fri Jul 29 12:09:33 2011 +0200
+++ b/MetaData.py	Fri Jul 29 14:45:13 2011 +0200
@@ -28,12 +28,19 @@
         #{'label':'Select Fields for Display','action':'indicateDisplayFieldsForm'},
         )
     
-    mappingSelectAttribute = 'type'
+    mappingSelectAttribute = None
     """the name of the attribute that can be used to select a mapping (if applicable)"""
     
-    def __init__(self,id,shortDescription='',description='',fields=''):
+    def __init__(self,id,title=None,shortDescription='',description='',fields=''):
         """initialize a new instance"""
         self.id = id
+        # title is tag name
+        if title:
+            self.title = title
+        else:
+            # assume id is tag name
+            self.title = id
+            
         self.shortDescription =shortDescription #label fuer link auf add page
         self.description=description #description of the method for link page
         self.fieldList=fields.split(",")[0:]
@@ -46,7 +53,10 @@
     
     def getTagName(self):
         """returns the tag name of this element"""
-        return self.shortDescription
+        if self.title:
+            return self.title
+        else:
+            return self.shortDescription
     
     def getXmlPath(self, omitRoot=False):
         """returns the xpath to this element"""
@@ -125,7 +135,11 @@
     def getMapFields(self, data):
         """returns dict with metadata description for data"""
         fields = {}
-        type = data['@type']
+        type = data.get('@type', None)
+        if not type:
+            logging.error("getMapFields: no @type!")
+            return fields
+        
         # get mapping from main/meta/bib
         mapping = self.getMapping(type)
         if mapping is None:
@@ -297,12 +311,17 @@
     changeMetaDataForm = PageTemplateFile('zpt/changeMetadata', globals())
     
     security.declarePublic('changeMetaData')
-    def changeMetaData(self,shortDescription,description,fields,metaDataServerUrl,RESPONSE=None):
+    def changeMetaData(self,title=None,shortDescription=None,description=None,mappingSelectAttribute=None,fields=None,metaDataServerUrl=None,RESPONSE=None):
         """Change Metadata"""
+        self.title = title
         self.shortDescription=shortDescription
         self.description=description
-        self.fieldList=fields.split(",")[0:]
+        self.mappingSelectAttribute=mappingSelectAttribute
+        if fields:
+            self.fieldList=fields.split(",")[0:]
+
         self.metaDataServerUrl=metaDataServerUrl
+            
         if RESPONSE is not None:
             RESPONSE.redirect('manage_main')