Skip to content

Commit

Permalink
fix case, where settings is False (when run in Plone 4 context)
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Nov 14, 2014
1 parent f1be8d2 commit 87e7822
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions plone/app/upgrade/v50/betas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@ def upgrade_markup_controlpanel_settings(context):
site_properties = portal_properties.site_properties
# get the new registry
registry = getUtility(IRegistry)

# XXX: Somehow this code is excecuted 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 = site_properties.default_contenttype

settings.default_type = site_properties.default_contenttype

forbidden_types = site_properties.getProperty('forbidden_contenttypes')
forbidden_types = list(forbidden_types) if forbidden_types else []
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()
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
])
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
])

0 comments on commit 87e7822

Please sign in to comment.