Skip to content

Commit

Permalink
Add upgrade step for mail control panel. Refs PLIP 10359.
Browse files Browse the repository at this point in the history
  • Loading branch information
khink committed Nov 15, 2014
1 parent 87e7822 commit c5f8e50
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
1.3.9 (unreleased)
------------------

- Add upgrade step for mail control panel. Refs PLIP 10359.
[jcerjak, khink]
- Add upgrade steps for markup control panel.
[thet]

Expand Down
35 changes: 35 additions & 0 deletions plone/app/upgrade/v50/betas.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
# -*- coding: utf-8 -*-
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IMailSchema
from Products.CMFPlone.interfaces import IMarkupSchema
from plone.registry.interfaces import IRegistry
from zope.component import getUtility
from zope.component.hooks import getSite


def upgrade_mail_controlpanel_settings(context):
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:
mail_settings = registry.forInterface(IMailSchema, prefix='plone')
except KeyError:
return
portal = getSite()
portal_properties = getToolByName(context, "portal_properties")

smtp_host = getattr(portal.MailHost, 'smtp_host', '')
mail_settings.smtp_host = unicode(smtp_host)

smtp_port = getattr(portal.MailHost, 'smtp_port', 25)
mail_settings.smtp_port = smtp_port

smtp_user_id = portal.MailHost.get('smtp_user_id')
mail_settings.smtp_user_id = smtp_user_id

smtp_pass = portal.MailHost.get('smtp_pass')
mail_settings.smtp_pass = smtp_pass

email_from_address = portal_properties.get('email_from_address')
mail_settings.email_from_address = email_from_address

email_from_name = portal_properties.get('email_from_name')
mail_settings.email_from_name = email_from_name


def upgrade_markup_controlpanel_settings(context):
Expand Down
6 changes: 6 additions & 0 deletions plone/app/upgrade/v50/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
handler=".betas.upgrade_markup_controlpanel_settings"
/>

<gs:upgradeStep
title="Upgrade mail control panel settings"
description="Take portal properties and put them in IMailSettings registry"
handler=".betas.upgrade_mail_controlpanel_settings"
/>

</gs:upgradeSteps>

</configure>
6 changes: 4 additions & 2 deletions plone/app/upgrade/v50/profiles/to_alpha3/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
prefix="plone" />
<records interface="Products.CMFPlone.interfaces.IMaintenanceSchema"
prefix="plone" />
<records interface="Products.CMFPlone.interfaces.IMailSchema"
prefix="plone" />
<records interface="Products.CMFPlone.interfaces.INavigationSchema"
prefix="plone" />
<records interface="Products.CMFPlone.interfaces.ISearchSchema"
Expand Down Expand Up @@ -813,12 +815,12 @@

<records prefix="plone.resources/rjs"
interface='Products.CMFPlone.interfaces.IResourceRegistry'>
<value key="js">++plone++static/components/r.js/dist/r.js</value>
<value key="js">++plone++static/components/r.js/dist/r.js</value>
</records>

<!-- legacy js -->


<records prefix="plone.resources/plone_javascript_variables"
interface='Products.CMFPlone.interfaces.IResourceRegistry'>
<value key="js">plone_javascript_variables.js</value>
Expand Down

1 comment on commit c5f8e50

@jcerjak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a new GS profile for beta upgrades (e.g. 'to_beta1') and move the registry.xml changes there.

Please sign in to comment.