changeset 11:a29665fa9c62

more work for non-bib metadata
author casties
date Fri, 29 Jul 2011 14:45:13 +0200
parents 68bc459c9f59
children 7f0e2b656e5c
files MetaData.py MetaDataFolder.py zpt/addMetadataForm.zpt zpt/changeMetadata.zpt
diffstat 4 files changed, 43 insertions(+), 17 deletions(-) [+]
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')
 
--- a/MetaDataFolder.py	Fri Jul 29 12:09:33 2011 +0200
+++ b/MetaDataFolder.py	Fri Jul 29 14:45:13 2011 +0200
@@ -166,7 +166,7 @@
     getFormattedLabel = getBibFormattedLabel
 
                 
-    def getDCFormatted(self,path):
+    def OLDgetDCFormatted(self,path):
         """get the metadata as dc set"""
         logging.debug("getDCFormatted(path=%s)"%path)
         namespace={ 'mpiwg':  "http://www.mpiwg-berlin.mpg.de/ns/mpiwg"}
--- a/zpt/addMetadataForm.zpt	Fri Jul 29 12:09:33 2011 +0200
+++ b/zpt/addMetadataForm.zpt	Fri Jul 29 14:45:13 2011 +0200
@@ -2,9 +2,11 @@
   <body>
     <form name="form" action="manage_addMetaData">
       <b> ID: </b><input type="text" name="id"><br><br>
+      <b> Tag name (=title): </b><input type="text" name="title"><br><br>
       <b> short description: </b><input type="text" size="100" name="shortDescription"><br><br>
       <b> Description: </b><textarea name="description" cols="80" rows="30"></textarea><br><br>
-      <b> Generic Metafields </b>
+
+<!--      <b> Generic Metafields </b>
       <ul>
       <li>separated by ","
       <li>only letters a-z, Numbers and '_' allowed
@@ -12,7 +14,9 @@
       </ul>
       <input type="text" name="fields" size="100"><br><br>
       <i> Name of the container Tag (optional)</i>      <input type="text" name="containerTag" size="20"><br><br>	
-      <input type="submit" value="Add" s><br><br>
+-->
+
+      <input type="submit" value="Add"><br><br>
     </form>
   </body>
 </html>
--- a/zpt/changeMetadata.zpt	Fri Jul 29 12:09:33 2011 +0200
+++ b/zpt/changeMetadata.zpt	Fri Jul 29 14:45:13 2011 +0200
@@ -5,9 +5,13 @@
 <!-- end of ZOPE management tabs -->
 
     <form name="form" action="changeMetaData">
-      <b> ShortDescription: </b><input type="text" name="shortDescription" size="100" tal:attributes="value python:here.shortDescription"><br><br>
-      <b> Description: </b><textarea name="description" tal:content="python:here.description" cols=80 rows=20></textarea><br><br>
-      <b> Generic Metafields </b>
+      <b>Tag name (title): </b><input type="text" name="title" size="10" tal:attributes="value python:here.title"><br><br>
+      <b>ShortDescription: </b><input type="text" name="shortDescription" size="80" tal:attributes="value python:here.shortDescription"><br><br>
+      <b>Description: </b><textarea name="description" tal:content="python:here.description" cols=80 rows=20></textarea><br><br>
+      <b>(optional) Attribute to select a mapping (mappingSelectAttribute):</b><input type="text" name="mappingSelectAttribute" size="10" tal:attributes="value python:here.mappingSelectAttribute"><br><br>
+
+
+<!--      <b>Generic Metafields </b>
       <ul>
       <li>separated by ","
       <li>only letters A-Z, Numbers and '_' allowed
@@ -17,10 +21,9 @@
 <input type="text" name="fields" tal:attributes="value here/getFieldList" size=100><br><br>
       
       <i> Container Tag </i><input type="text" name="containerTag" tal:attributes="value python:getattr(here,'containerTag','')"><br><br> 
-  
-  <i>Server f&uuml;r xml files (e.g. url des Textservlets von digilib als python formaated String mit %s wo der Pfad eingesetzt werden soll.)	
-  </i><br>
-  <input type="text" size="100" name="metaDataServerUrl" tal:attributes="value python:getattr(here,'metaDataServerUrl','')"><br><br> 
-  
+
+  <i>Server for XML files (e.g. url of Texter-servlet)</i><br>
+  <input type="text" size="80" name="metaDataServerUrl" tal:attributes="value python:getattr(here,'metaDataServerUrl','')"><br><br> 
+-->    
       <input type="submit" value="Change"><br><br>
     </form>