Exemplo n.º 1
0
def upgrade_dcmi_metadata(tool):
    """2.1.x to 2.2.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    metadata_tool = getToolByName(tool, 'portal_metadata')
    if getattr(aq_base(metadata_tool), 'DCMI', None) is None:
        if getattr(aq_base(metadata_tool), '_DCMI', None) is None:
            metadata_tool.DCMI = MetadataSchema('DCMI', _DCMI_ELEMENT_SPECS)
        else:
            metadata_tool.DCMI = metadata_tool._DCMI
            del metadata_tool._DCMI
    logger.info('Dublin Core metadata definition updated.')
Exemplo n.º 2
0
def upgrade_dcmi_metadata(tool):
    """1.6.x to 2.0.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    metadata_tool = getToolByName(tool, 'portal_metadata')
    old_specs = getattr(metadata_tool, 'element_specs', None)
    if old_specs is not None:
        del metadata_tool.element_specs
        dcmi = metadata_tool._DCMI = MetadataSchema('DCMI',
                                                    _DCMI_ELEMENT_SPECS)
        for element_id, old_spec in old_specs.items():
            new_spec = dcmi.getElementSpec(element_id)
            for typ, policy in old_spec.listPolicies():
                if typ is not None:
                    new_spec.addPolicy(typ)
                tp = new_spec.getPolicy(typ)
                tp.edit(is_required=policy.isRequired(),
                        supply_default=policy.supplyDefault(),
                        default_value=policy.defaultValue(),
                        enforce_vocabulary=policy.enforceVocabulary(),
                        allowed_vocabulary=policy.allowedVocabulary())
    logger.info('Dublin Core metadata definition updated.')