Skip to content

Commit

Permalink
These attributes do not exist anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Oct 23, 2016
1 parent aac74f6 commit 8066f51
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
7 changes: 7 additions & 0 deletions plone/app/upgrade/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,10 @@ def updateIconsInBrains(context, typesToUpdate=None):
i += 1
pghandler.finish()
logger.info('Updated `getIcon` metadata.')


def get_property(context, property_name, default_value=None):
try:
return getattr(context, property_name, default_value)
except AttributeError:
return default_value
31 changes: 25 additions & 6 deletions plone/app/upgrade/v50/alphas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Products.CMFPlone.interfaces import ISearchSchema
from Products.CMFPlone.interfaces import ISiteSchema
from plone.app.upgrade.utils import loadMigrationProfile
from plone.app.upgrade.utils import get_property
from plone.app.upgrade.v40.alphas import cleanUpToolRegistry
from plone.app.vocabularies.types import BAD_TYPES
from plone.keyring.interfaces import IKeyManager
Expand Down Expand Up @@ -193,7 +194,11 @@ def upgrade_editing_controlpanel_settings(context):
# ignore the setting.
if site_properties.default_editor != 'Kupu':
settings.default_editor = site_properties.default_editor
settings.lock_on_ttw_edit = site_properties.lock_on_ttw_edit
settings.lock_on_ttw_edit = get_property(
site_properties,
'lock_on_ttw_edit',
None,
)


def upgrade_maintenance_controlpanel_settings(context):
Expand All @@ -218,7 +223,11 @@ def upgrade_maintenance_controlpanel_settings(context):
except KeyError:
settings = False
if settings:
settings.days = site_properties.number_of_days_to_keep
settings.days = get_property(
site_properties,
'number_of_days_to_keep',
None,
)


def upgrade_navigation_controlpanel_settings(context):
Expand Down Expand Up @@ -252,7 +261,11 @@ def upgrade_navigation_controlpanel_settings(context):
settings.show_all_parents = navigation_properties.getProperty(
'showAllParents')
allTypes = types_tool.listContentTypes()
blacklist = navigation_properties.metaTypesNotToList
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
Expand Down Expand Up @@ -289,9 +302,14 @@ def upgrade_search_controlpanel_settings(context):

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 site_properties.types_not_searched and
if t in types_not_searched and
t not in BAD_TYPES
])

Expand Down Expand Up @@ -319,7 +337,8 @@ def upgrade_site_controlpanel_settings(context):
except KeyError:
settings = False
settings.site_title = unicode(portal.title)
settings.webstats_js = unicode(site_properties.webstats_js)
settings.enable_sitemap = site_properties.enable_sitemap
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
7 changes: 6 additions & 1 deletion plone/app/upgrade/v50/betas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.linkintegrity.upgrades import migrate_linkintegrity_relations
from plone.app.upgrade.utils import loadMigrationProfile
from plone.app.upgrade.utils import get_property
from plone.registry.interfaces import IRegistry
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.utils import getToolByName
Expand Down Expand Up @@ -135,7 +136,11 @@ def upgrade_markup_controlpanel_settings(context):
except KeyError:
settings = False
if settings:
settings.default_type = site_properties.default_contenttype
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 []
Expand Down

0 comments on commit 8066f51

Please sign in to comment.