def upgrade_site_controlpanel_settings(context): """Copy site control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties portal = getSite() # get the new registry registry = getUtility(IRegistry) # XXX: Somehow this code is executed for old migration steps as well # ( < Plone 4 ) and breaks because there is no registry. Looking up the # registry interfaces with 'check=False' will not work, because it will # return a settings object and then fail when we try to access the # attributes. try: settings = registry.forInterface( ISiteSchema, prefix='plone', ) except KeyError: settings = False settings.site_title = unicode(portal.title) webstat_js = get_property(site_properties, 'webstats_js', '') settings.webstats_js = unicode(webstat_js) settings.enable_sitemap = get_property(site_properties, 'enable_sitemap') if site_properties.hasProperty('exposeDCMetaTags'): settings.exposeDCMetaTags = site_properties.exposeDCMetaTags
def upgrade_search_controlpanel_settings(context): """Copy search control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties types_tool = getToolByName(context, 'portal_types') # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( ISearchSchema, prefix='plone', ) if site_properties.hasProperty('enable_livesearch'): settings.enable_livesearch = site_properties.enable_livesearch types_not_searched = get_property( site_properties, 'types_not_searched', default_value=[], ) settings.types_not_searched = tuple([ t for t in types_tool.listContentTypes() if t in types_not_searched and t not in BAD_TYPES ])
def upgrade_markup_controlpanel_settings(context): """Copy markup control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( IMarkupSchema, prefix='plone', ) settings.default_type = get_property( site_properties, 'default_contenttype', None, ) forbidden_types = site_properties.getProperty('forbidden_contenttypes') forbidden_types = list(forbidden_types) if forbidden_types else [] portal_transforms = getToolByName(context, 'portal_transforms') allowable_types = portal_transforms.listAvailableTextInputs() settings.allowed_types = tuple([ _type for _type in allowable_types if _type not in forbidden_types and _type not in 'text/x-plone-outputfilters-html' # removed, as in plone.app.vocabularies.types # noqa ])
def upgrade_markup_controlpanel_settings(context): """Copy markup control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( IMarkupSchema, prefix='plone', ) settings.default_type = get_property( site_properties, 'default_contenttype', None, ) forbidden_types = site_properties.getProperty('forbidden_contenttypes') forbidden_types = list(forbidden_types) if forbidden_types else [] portal_transforms = getToolByName(context, 'portal_transforms') allowable_types = portal_transforms.listAvailableTextInputs() settings.allowed_types = tuple([ _type for _type in allowable_types if _type not in forbidden_types and _type not in 'text/x-plone-outputfilters-html' # removed, as in plone.app.vocabularies.types # noqa ])
def upgrade_navigation_controlpanel_settings(context): """Copy navigation control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties navigation_properties = portal_properties.navtree_properties types_tool = getToolByName(context, 'portal_types') # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( INavigationSchema, prefix='plone', ) settings.disable_folder_sections = site_properties.getProperty( 'disable_folder_sections') settings.disable_nonfolderish_sections = site_properties.getProperty( 'disable_nonfolderish_sections') settings.show_all_parents = navigation_properties.getProperty( 'showAllParents') allTypes = types_tool.listContentTypes() blacklist = get_property( navigation_properties, 'metaTypesNotToList', default_value=[], ) settings.displayed_types = tuple( [t for t in allTypes if t not in blacklist and t not in BAD_TYPES]) settings.enable_wf_state_filtering = navigation_properties.getProperty( 'enable_wf_state_filtering') settings.wf_states_to_show = navigation_properties.getProperty( 'wf_states_to_show')
def upgrade_search_controlpanel_settings(context): """Copy search control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties types_tool = getToolByName(context, "portal_types") # get the new registry registry = getUtility(IRegistry) # XXX: Somehow this code is executed for old migration steps as well # ( < Plone 4 ) and breaks because there is no registry. Looking up the # registry interfaces with 'check=False' will not work, because it will # return a settings object and then fail when we try to access the # attributes. try: settings = registry.forInterface( ISearchSchema, prefix='plone', ) except KeyError: settings = False if site_properties.hasProperty('enable_livesearch'): settings.enable_livesearch = site_properties.enable_livesearch types_not_searched = get_property( site_properties, 'types_not_searched', default_value=[], ) settings.types_not_searched = tuple([ t for t in types_tool.listContentTypes() if t in types_not_searched and t not in BAD_TYPES ])
def upgrade_maintenance_controlpanel_settings(context): """Copy maintenance control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) # XXX: Somehow this code is executed for old migration steps as well # ( < Plone 4 ) and breaks because there is no registry. Looking up the # registry interfaces with 'check=False' will not work, because it will # return a settings object and then fail when we try to access the # attributes. try: settings = registry.forInterface( IMaintenanceSchema, prefix='plone', ) except KeyError: settings = False if settings: settings.days = get_property( site_properties, 'number_of_days_to_keep', None, )
def upgrade_site_controlpanel_settings(context): """Copy site control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties portal = getSite() # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( ISiteSchema, prefix='plone', ) settings.site_title = safe_unicode(portal.title) webstat_js = get_property(site_properties, 'webstats_js', '') settings.webstats_js = safe_unicode(webstat_js) settings.enable_sitemap = get_property(site_properties, 'enable_sitemap') if site_properties.hasProperty('exposeDCMetaTags'): settings.exposeDCMetaTags = site_properties.exposeDCMetaTags
def upgrade_editing_controlpanel_settings(context): """Copy editing control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) # XXX: Somehow this code is executed for old migration steps as well # ( < Plone 4 ) and breaks because there is no registry. Looking up the # registry interfaces with 'check=False' will not work, because it will # return a settings object and then fail when we try to access the # attributes. try: settings = registry.forInterface( IEditingSchema, prefix='plone', ) except KeyError: settings = False if settings: # migrate the old site properties to the new registry if site_properties.hasProperty('visible_ids'): settings.visible_ids = site_properties.visible_ids if site_properties.hasProperty('enable_link_integrity_checks'): settings.enable_link_integrity_checks = \ site_properties.enable_link_integrity_checks if site_properties.hasProperty('ext_editor'): settings.ext_editor = site_properties.ext_editor # settings.available_editors = site_properties.available_editors # Kupu will not be available as editor in Plone 5. Therefore we just # ignore the setting. But there may be others (like an empty string) # that will give an error too. So we validate the value. try: IEditingSchema['default_editor'].validate( site_properties.default_editor) except ConstraintNotSatisfied: logger.warn('Ignoring invalid site_properties.default_editor %r.', site_properties.default_editor) else: settings.default_editor = site_properties.default_editor settings.lock_on_ttw_edit = get_property( site_properties, 'lock_on_ttw_edit', None, )
def upgrade_navigation_controlpanel_settings(context): """Copy navigation control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties navigation_properties = portal_properties.navtree_properties types_tool = getToolByName(context, "portal_types") # get the new registry registry = getUtility(IRegistry) # XXX: Somehow this code is executed for old migration steps as well # ( < Plone 4 ) and breaks because there is no registry. Looking up the # registry interfaces with 'check=False' will not work, because it will # return a settings object and then fail when we try to access the # attributes. try: settings = registry.forInterface( INavigationSchema, prefix='plone', ) except KeyError: settings = False if settings: settings.disable_folder_sections = site_properties.getProperty( 'disable_folder_sections') settings.disable_nonfolderish_sections = site_properties.getProperty( 'disable_nonfolderish_sections') settings.show_all_parents = navigation_properties.getProperty( 'showAllParents') allTypes = types_tool.listContentTypes() blacklist = get_property( navigation_properties, 'metaTypesNotToList', default_value=[], ) settings.displayed_types = tuple([ t for t in allTypes if t not in blacklist and t not in BAD_TYPES ]) settings.enable_wf_state_filtering = navigation_properties.getProperty( 'enable_wf_state_filtering') settings.wf_states_to_show = navigation_properties.getProperty( 'wf_states_to_show')
def upgrade_maintenance_controlpanel_settings(context): """Copy maintenance control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( IMaintenanceSchema, prefix='plone', ) settings.days = get_property( site_properties, 'number_of_days_to_keep', None, )
def upgrade_editing_controlpanel_settings(context): """Copy editing control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( IEditingSchema, prefix='plone', ) # migrate the old site properties to the new registry if site_properties.hasProperty('visible_ids'): settings.visible_ids = site_properties.visible_ids if site_properties.hasProperty('enable_link_integrity_checks'): settings.enable_link_integrity_checks = \ site_properties.enable_link_integrity_checks if site_properties.hasProperty('ext_editor'): settings.ext_editor = site_properties.ext_editor # settings.available_editors = site_properties.available_editors # Kupu will not be available as editor in Plone 5. Therefore we just # ignore the setting. But there may be others (like an empty string) # that will give an error too. So we validate the value. try: IEditingSchema['default_editor'].validate( site_properties.default_editor) except ConstraintNotSatisfied: logger.warning( 'Ignoring invalid site_properties.default_editor %r.', site_properties.default_editor) except AttributeError: logger.warning( 'Ignoring non existing attribute site_properties.default_editor.') else: settings.default_editor = site_properties.default_editor settings.lock_on_ttw_edit = get_property( site_properties, 'lock_on_ttw_edit', None, )
def upgrade_editing_controlpanel_settings(context): """Copy editing control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( IEditingSchema, prefix='plone', ) # migrate the old site properties to the new registry if site_properties.hasProperty('visible_ids'): settings.visible_ids = site_properties.visible_ids if site_properties.hasProperty('enable_link_integrity_checks'): settings.enable_link_integrity_checks = \ site_properties.enable_link_integrity_checks if site_properties.hasProperty('ext_editor'): settings.ext_editor = site_properties.ext_editor # settings.available_editors = site_properties.available_editors # Kupu will not be available as editor in Plone 5. Therefore we just # ignore the setting. But there may be others (like an empty string) # that will give an error too. So we validate the value. try: IEditingSchema['default_editor'].validate( site_properties.default_editor) except ConstraintNotSatisfied: logger.warning('Ignoring invalid site_properties.default_editor %r.', site_properties.default_editor) except AttributeError: logger.warning( 'Ignoring non existing attribute site_properties.default_editor.') else: settings.default_editor = site_properties.default_editor settings.lock_on_ttw_edit = get_property( site_properties, 'lock_on_ttw_edit', None, )
def upgrade_markup_controlpanel_settings(context): """Copy markup control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, "portal_properties") site_properties = portal_properties.site_properties # get the new registry registry = getUtility(IRegistry) # XXX: Somehow this code is executed for old migration steps as well # ( < Plone 4 ) and breaks because there is no registry. Looking up the # registry interfaces with 'check=False' will not work, because it will # return a settings object and then fail when we try to access the # attributes. try: settings = registry.forInterface( IMarkupSchema, prefix='plone', ) except KeyError: settings = False if settings: settings.default_type = get_property( site_properties, 'default_contenttype', None, ) forbidden_types = site_properties.getProperty('forbidden_contenttypes') forbidden_types = list(forbidden_types) if forbidden_types else [] portal_transforms = getToolByName(context, 'portal_transforms') allowable_types = portal_transforms.listAvailableTextInputs() settings.allowed_types = tuple([ _type for _type in allowable_types if _type not in forbidden_types and _type not in 'text/x-plone-outputfilters-html' # removed, as in plone.app.vocabularies.types # noqa ])
def upgrade_navigation_controlpanel_settings(context): """Copy navigation control panel settings from portal properties into the new registry. """ # get the old site properties portal_properties = getToolByName(context, 'portal_properties') site_properties = portal_properties.site_properties navigation_properties = portal_properties.navtree_properties types_tool = getToolByName(context, 'portal_types') # get the new registry registry = getUtility(IRegistry) settings = registry.forInterface( INavigationSchema, prefix='plone', ) settings.disable_folder_sections = site_properties.getProperty( 'disable_folder_sections') settings.disable_nonfolderish_sections = site_properties.getProperty( 'disable_nonfolderish_sections') settings.show_all_parents = navigation_properties.getProperty( 'showAllParents') allTypes = types_tool.listContentTypes() blacklist = get_property( navigation_properties, 'metaTypesNotToList', default_value=[], ) settings.displayed_types = tuple([ t for t in allTypes if t not in blacklist and t not in BAD_TYPES ]) settings.enable_wf_state_filtering = navigation_properties.getProperty( 'enable_wf_state_filtering') settings.wf_states_to_show = navigation_properties.getProperty( 'wf_states_to_show')