Repository: plone.app.upgrade
Branch: refs/heads/master
Date: 2014-11-14T12:02:41+01:00
Author: Johannes Raggam (thet) <raggam-nl@adm.at>
Commit: https://github.com/plone/plone.app.upgrade/commit/f1be8d22d2bb4bc699bc5cf2134e5096bf19c40b

Add upgrade steps for markup control panel.

Files changed:
M CHANGES.rst
M plone/app/upgrade/v50/alphas.py
M plone/app/upgrade/v50/betas.py
M plone/app/upgrade/v50/configure.zcml

diff --git a/CHANGES.rst b/CHANGES.rst
index e3684e1..66d69fd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,8 @@ Changelog
 1.3.9 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Add upgrade steps for markup control panel.
+  [thet]
 
 
 1.3.8 (2014-11-01)
diff --git a/plone/app/upgrade/v50/alphas.py b/plone/app/upgrade/v50/alphas.py
index d71fec7..b4a56c0 100644
--- a/plone/app/upgrade/v50/alphas.py
+++ b/plone/app/upgrade/v50/alphas.py
@@ -22,9 +22,6 @@
 
 logger = logging.getLogger('plone.app.upgrade')
 
-
-logger = logging.getLogger('plone.app.upgrade')
-
 TOOLS_TO_REMOVE = ['portal_actionicons',
                    'portal_calendar',
                    'portal_interface',
@@ -170,7 +167,8 @@ def upgrade_editing_controlpanel_settings(context):
         settings.enable_link_integrity_checks = \
             site_properties.enable_link_integrity_checks
         settings.ext_editor = site_properties.ext_editor
-        #settings.available_editors = site_properties.available_editors
+        # settings.available_editors = site_properties.available_editors
+
         # Kupu will not be available as editor in Plone 5. Therefore we just
         # ignore the setting.
         if site_properties.default_editor != 'Kupu':
diff --git a/plone/app/upgrade/v50/betas.py b/plone/app/upgrade/v50/betas.py
index e69de29..656959b 100644
--- a/plone/app/upgrade/v50/betas.py
+++ b/plone/app/upgrade/v50/betas.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone.interfaces import IMarkupSchema
+from plone.registry.interfaces import IRegistry
+from zope.component import getUtility
+
+
+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)
+
+    try:
+        settings = registry.forInterface(
+            IMarkupSchema,
+            prefix='plone',
+        )
+    except KeyError:
+        settings = False
+
+    settings.default_type = site_properties.default_contenttype
+
+    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
+    ])
diff --git a/plone/app/upgrade/v50/configure.zcml b/plone/app/upgrade/v50/configure.zcml
index b4dca3d..b53fe05 100644
--- a/plone/app/upgrade/v50/configure.zcml
+++ b/plone/app/upgrade/v50/configure.zcml
@@ -81,4 +81,18 @@
 
     </gs:upgradeSteps>
 
+
+    <gs:upgradeSteps
+        source="5003"
+        destination="5004"
+        profile="Products.CMFPlone:plone">
+
+       <gs:upgradeStep
+           title="Upgrade markup control panel settings"
+           description=""
+           handler=".betas.upgrade_markup_controlpanel_settings"
+           />
+
+    </gs:upgradeSteps>
+
 </configure>


Repository: plone.app.upgrade
Branch: refs/heads/master
Date: 2014-11-14T13:42:38+01:00
Author: Johannes Raggam (thet) <raggam-nl@adm.at>
Commit: https://github.com/plone/plone.app.upgrade/commit/87e7822daf274cf196e6bc2e08a6b5bd9759498e

fix case, where settings is False (when run in Plone 4 context)

Files changed:
M plone/app/upgrade/v50/betas.py

diff --git a/plone/app/upgrade/v50/betas.py b/plone/app/upgrade/v50/betas.py
index 656959b..0b8ae9f 100644
--- a/plone/app/upgrade/v50/betas.py
+++ b/plone/app/upgrade/v50/betas.py
@@ -14,7 +14,11 @@ 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,
@@ -22,17 +26,17 @@ def upgrade_markup_controlpanel_settings(context):
         )
     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
+        ])