Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2014-11-15T18:16:13+01:00 Author: Kees Hink (khink) <keeshink@gmail.com> Commit: plone/plone.app.upgrade@c5f8e50 Add upgrade step for mail control panel. Refs PLIP 10359. Files changed: M CHANGES.rst M plone/app/upgrade/v50/betas.py M plone/app/upgrade/v50/configure.zcml M plone/app/upgrade/v50/profiles/to_alpha3/registry.xml diff --git a/CHANGES.rst b/CHANGES.rst index 66d69fd..eeb195f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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] diff --git a/plone/app/upgrade/v50/betas.py b/plone/app/upgrade/v50/betas.py index 0b8ae9f..a6d9225 100644 --- a/plone/app/upgrade/v50/betas.py +++ b/plone/app/upgrade/v50/betas.py @@ -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): diff --git a/plone/app/upgrade/v50/configure.zcml b/plone/app/upgrade/v50/configure.zcml index b53fe05..cb79fd8 100644 --- a/plone/app/upgrade/v50/configure.zcml +++ b/plone/app/upgrade/v50/configure.zcml @@ -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> diff --git a/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml b/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml index ae456b6..94c1214 100644 --- a/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml +++ b/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml @@ -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" @@ -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> Repository: plone.app.upgrade Branch: refs/heads/master Date: 2014-12-12T16:53:00+01:00 Author: Timo Stollenwerk (tisto) <tisto@plone.org> Commit: plone/plone.app.upgrade@9c799e2 Merge pull request #20 from plone/plip10359-mail-controlpanel Add upgrade step for mail control panel. Refs PLIP 10359. Files changed: M CHANGES.rst M plone/app/upgrade/v50/betas.py M plone/app/upgrade/v50/configure.zcml M plone/app/upgrade/v50/profiles/to_alpha3/registry.xml diff --git a/CHANGES.rst b/CHANGES.rst index 66d69fd..eeb195f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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] diff --git a/plone/app/upgrade/v50/betas.py b/plone/app/upgrade/v50/betas.py index 0b8ae9f..a6d9225 100644 --- a/plone/app/upgrade/v50/betas.py +++ b/plone/app/upgrade/v50/betas.py @@ -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): diff --git a/plone/app/upgrade/v50/configure.zcml b/plone/app/upgrade/v50/configure.zcml index b53fe05..cb79fd8 100644 --- a/plone/app/upgrade/v50/configure.zcml +++ b/plone/app/upgrade/v50/configure.zcml @@ -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> diff --git a/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml b/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml index ae456b6..94c1214 100644 --- a/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml +++ b/plone/app/upgrade/v50/profiles/to_alpha3/registry.xml @@ -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" @@ -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>
- Loading branch information