Mercurial > hg > MetaDataProvider
view MetaDataMapping.py @ 0:9f9d9be26e53
first checkin in Mercurial (see history in SVN)
author | casties |
---|---|
date | Mon, 25 Jul 2011 16:50:48 +0200 |
parents | |
children | e4bae49e657b |
line wrap: on
line source
from OFS.Folder import Folder from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Globals import package_home from AccessControl import ClassSecurityInfo import os.path import urllib import logging import urlparse # TODO: which xml toolkit? import amara import xml.sax.saxutils import xml.dom.minidom import xml.etree.ElementTree as ET # TODO: do we need this? #from Products.OSA_system2 import OSAS_helpers #from Products.OSA_system2.OSAS_metadata import OSAS_Metadata,OSAS_MetadataMapping from OSAS_metadata import OSAS_MetadataMapping class MetaDataMapping(OSAS_MetadataMapping): """Metadata mapping object representing a fixed set of sub-elements.""" meta_type="MetadataMapping" manage_options = SimpleItem.manage_options+( {'label':'Main Config','action':'changeMetadataMappingForm'}, ) fields = {} """dict containing element descriptions""" fieldList = [] """list of element names in preferred order""" def __init__(self,id,title,fields): """init @param id: id @param title: title fuer zope navigation @param fields: dictionary mit Namen der zugelassenen Metadaten als key und Tripel als Werte (human readable, tag version,explanation """ self.id=id self.title=title for fieldName in fields.keys(): self.fields[fieldName] = fields[fieldName] manage_addMetaDataMappingForm = PageTemplateFile('zpt/addMetadataMappingForm', globals()) def manage_addMetaDataMapping(self,idOfObject,titleOfObject,RESPONSE=None): """add the MetapdataMapping""" argList={} for arg in self.fieldList: if not (arg in ['idOfObject','titleOfObject']): argList[arg]=(self.REQUEST.form[arg],self.REQUEST.form['label_'+arg],self.REQUEST.form['explanation_'+arg],self.REQUEST.form['status_'+arg],self.REQUEST.form['values_'+arg]) newObj=MetaDataMapping(idOfObject,titleOfObject,argList) self._setObject(idOfObject,newObj) if RESPONSE is not None: RESPONSE.redirect('manage_main')