Repository: plone.app.contentrules
Branch: refs/heads/master
Date: 2014-11-15T15:22:48+01:00
Author: Kees Hink (khink) <keeshink@gmail.com>
Commit: https://github.com/plone/plone.app.contentrules/commit/ae4204216a88c284558ebef1015abb9a8eb6e157

Fetch email settings from registry instead of properties. Refs PLIP 10359.

Files changed:
M CHANGES.rst
M plone/app/contentrules/actions/mail.py
M plone/app/contentrules/tests/test_action_mail.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 5424c67..82d9890 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,8 @@ Changelog
 4.0.1 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Fetch email settings from registry instead of properties. Refs PLIP 10359.
+  [jcerjak, khink]
 
 
 4.0.0 (2014-10-23)
diff --git a/plone/app/contentrules/actions/mail.py b/plone/app/contentrules/actions/mail.py
index 5cde935..910d885 100644
--- a/plone/app/contentrules/actions/mail.py
+++ b/plone/app/contentrules/actions/mail.py
@@ -3,8 +3,10 @@
 from smtplib import SMTPException
 
 from plone.contentrules.rule.interfaces import IRuleElementData, IExecutable
+from plone.registry.interfaces import IRegistry
 from plone.stringinterp.interfaces import IStringInterpolator
 from zope.component import adapts
+from zope.component import getUtility
 from zope.component.interfaces import ComponentLookupError
 from zope.formlib import form
 from zope.interface import Interface, implements
@@ -14,6 +16,7 @@
 from Acquisition import aq_inner
 from OFS.SimpleItem import SimpleItem
 from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone.interfaces.controlpanel import IMailSchema
 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
 from Products.MailHost.MailHost import MailHostError
 from Products.statusmessages.interfaces import IStatusMessage
@@ -79,6 +82,10 @@ def __init__(self, context, element, event):
         self.context = context
         self.element = element
         self.event = event
+        registry = getUtility(IRegistry)
+        self.mail_settings = registry.forInterface(IMailSchema,
+                                                   prefix='plone')
+
 
     def __call__(self):
         mailhost = getToolByName(aq_inner(self.context), "MailHost")
@@ -101,7 +108,7 @@ def __call__(self):
         if not source:
             # no source provided, looking for the site wide from email
             # address
-            from_address = portal.getProperty('email_from_address')
+            from_address = self.mail_settings.email_from_address
             if not from_address:
                 # the mail can't be sent. Try to inform the user
                 request = getRequest()
@@ -113,7 +120,7 @@ def __call__(self):
                     messages.add(msg, type=u"error")
                 return False
 
-            from_name = portal.getProperty('email_from_name').strip('"')
+            from_name = self.mail_settings.email_from_name.strip('"')
             source = '"%s" <%s>' % (from_name, from_address)
 
         recip_string = interpolator(self.element.recipients)
diff --git a/plone/app/contentrules/tests/test_action_mail.py b/plone/app/contentrules/tests/test_action_mail.py
index ffcff67..1cd1ca8 100644
--- a/plone/app/contentrules/tests/test_action_mail.py
+++ b/plone/app/contentrules/tests/test_action_mail.py
@@ -10,7 +10,9 @@
 from plone.app.contentrules.actions.mail import MailAction, MailEditForm, MailAddForm
 from plone.contentrules.engine.interfaces import IRuleStorage
 from plone.contentrules.rule.interfaces import IRuleAction, IExecutable
+from plone.registry.interfaces import IRegistry
 
+from Products.CMFPlone.interfaces.controlpanel import IMailSchema
 from Products.MailHost.interfaces import IMailHost
 from Products.MailHost.MailHost import MailHost
 
@@ -141,7 +143,10 @@ def testExecuteNoSource(self):
         # and will return False for the unsent message
         self.assertEqual(ex(), False)
         # if we provide a site mail address the message sends correctly
-        sm.manage_changeProperties({'email_from_address': 'manager@portal.be', 'email_from_name': 'plone@rulez'})
+        registry = getUtility(IRegistry)
+        mail_settings = registry.forInterface(IMailSchema, prefix='plone')
+        mail_settings.email_from_address = 'manager@portal.be'
+        mail_settings.email_from_name = u'plone@rulez'
         ex()
         self.assertTrue(isinstance(dummyMailHost.sent[0], Message))
         mailSent = dummyMailHost.sent[0]


Repository: plone.app.contentrules
Branch: refs/heads/master
Date: 2014-11-15T15:25:52+01:00
Author: Kees Hink (khink) <keeshink@gmail.com>
Commit: https://github.com/plone/plone.app.contentrules/commit/7d31cfc904b660d650f5175020ab998645ca51b9

Fix changelog layout.

Files changed:
M CHANGES.rst

diff --git a/CHANGES.rst b/CHANGES.rst
index 82d9890..780c534 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,8 @@ Changelog
 4.0.1 (unreleased)
 ------------------
 
-- Fetch email settings from registry instead of properties. Refs PLIP 10359.
+- Fetch email settings from registry instead of properties.
+  Refs PLIP 10359.
   [jcerjak, khink]
 
 


Repository: plone.app.contentrules
Branch: refs/heads/master
Date: 2014-12-12T13:47:37+01:00
Author: Timo Stollenwerk (tisto) <tisto@plone.org>
Commit: https://github.com/plone/plone.app.contentrules/commit/5273e342f24c8d1870fcc52ad5b8f95bcb584943

Merge pull request #9 from plone/plip10359-mail-controlpanel

Fetch email settings from registry instead of properties. PLIP 10359

Files changed:
M CHANGES.rst
M plone/app/contentrules/actions/mail.py
M plone/app/contentrules/tests/test_action_mail.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 5424c67..780c534 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,9 @@ Changelog
 4.0.1 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Fetch email settings from registry instead of properties.
+  Refs PLIP 10359.
+  [jcerjak, khink]
 
 
 4.0.0 (2014-10-23)
diff --git a/plone/app/contentrules/actions/mail.py b/plone/app/contentrules/actions/mail.py
index 5cde935..910d885 100644
--- a/plone/app/contentrules/actions/mail.py
+++ b/plone/app/contentrules/actions/mail.py
@@ -3,8 +3,10 @@
 from smtplib import SMTPException
 
 from plone.contentrules.rule.interfaces import IRuleElementData, IExecutable
+from plone.registry.interfaces import IRegistry
 from plone.stringinterp.interfaces import IStringInterpolator
 from zope.component import adapts
+from zope.component import getUtility
 from zope.component.interfaces import ComponentLookupError
 from zope.formlib import form
 from zope.interface import Interface, implements
@@ -14,6 +16,7 @@
 from Acquisition import aq_inner
 from OFS.SimpleItem import SimpleItem
 from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone.interfaces.controlpanel import IMailSchema
 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
 from Products.MailHost.MailHost import MailHostError
 from Products.statusmessages.interfaces import IStatusMessage
@@ -79,6 +82,10 @@ def __init__(self, context, element, event):
         self.context = context
         self.element = element
         self.event = event
+        registry = getUtility(IRegistry)
+        self.mail_settings = registry.forInterface(IMailSchema,
+                                                   prefix='plone')
+
 
     def __call__(self):
         mailhost = getToolByName(aq_inner(self.context), "MailHost")
@@ -101,7 +108,7 @@ def __call__(self):
         if not source:
             # no source provided, looking for the site wide from email
             # address
-            from_address = portal.getProperty('email_from_address')
+            from_address = self.mail_settings.email_from_address
             if not from_address:
                 # the mail can't be sent. Try to inform the user
                 request = getRequest()
@@ -113,7 +120,7 @@ def __call__(self):
                     messages.add(msg, type=u"error")
                 return False
 
-            from_name = portal.getProperty('email_from_name').strip('"')
+            from_name = self.mail_settings.email_from_name.strip('"')
             source = '"%s" <%s>' % (from_name, from_address)
 
         recip_string = interpolator(self.element.recipients)
diff --git a/plone/app/contentrules/tests/test_action_mail.py b/plone/app/contentrules/tests/test_action_mail.py
index ffcff67..1cd1ca8 100644
--- a/plone/app/contentrules/tests/test_action_mail.py
+++ b/plone/app/contentrules/tests/test_action_mail.py
@@ -10,7 +10,9 @@
 from plone.app.contentrules.actions.mail import MailAction, MailEditForm, MailAddForm
 from plone.contentrules.engine.interfaces import IRuleStorage
 from plone.contentrules.rule.interfaces import IRuleAction, IExecutable
+from plone.registry.interfaces import IRegistry
 
+from Products.CMFPlone.interfaces.controlpanel import IMailSchema
 from Products.MailHost.interfaces import IMailHost
 from Products.MailHost.MailHost import MailHost
 
@@ -141,7 +143,10 @@ def testExecuteNoSource(self):
         # and will return False for the unsent message
         self.assertEqual(ex(), False)
         # if we provide a site mail address the message sends correctly
-        sm.manage_changeProperties({'email_from_address': 'manager@portal.be', 'email_from_name': 'plone@rulez'})
+        registry = getUtility(IRegistry)
+        mail_settings = registry.forInterface(IMailSchema, prefix='plone')
+        mail_settings.email_from_address = 'manager@portal.be'
+        mail_settings.email_from_name = u'plone@rulez'
         ex()
         self.assertTrue(isinstance(dummyMailHost.sent[0], Message))
         mailSent = dummyMailHost.sent[0]