[Testbot] Plone 5.0 - Python 2.7 - Build # 3189 - Fixed! - 0 failure(s)

jenkins at plone.org jenkins at plone.org
Wed Sep 17 03:37:01 UTC 2014


-------------------------------------------------------------------------------
Plone 5.0 - Python 2.7 - Build # 3189 - Fixed!
-------------------------------------------------------------------------------

http://jenkins.plone.org/job/plone-5.0-python-2.7/3189/


-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------

Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-09-16T21:06:31-05:00
Author: Nathan Van Gheem (vangheem) <vangheem at gmail.com>
Commit: https://github.com/plone/Products.CMFPlone/commit/e008e291f1cc0c0951ea0f59fafad06e005942d0

Revert "Remove some patches"

Files changed:
A Products/CMFPlone/patches/securemailhost.py
M CHANGES.rst
M Products/CMFPlone/patches/__init__.py
M Products/CMFPlone/patches/csrf.py
M Products/CMFPlone/patches/iso8601.py
M Products/CMFPlone/patches/sendmail.py
M Products/CMFPlone/patches/unicodeFallbackPatch.py

diff --git a/CHANGES.rst b/CHANGES.rst
index dc9e341..83be87c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,9 +7,6 @@ Changelog
 
 5.0a3 (unreleased)
 ------------------
-- remove BBB code-patches for securemailhost. warn explicit if DateTime.ISO
-  is called. Remove CMF 2.3 compat. Adresses issue #109.
-  [jensens]
 
 - type controlpanel: Resolved problem with workflow selection form as it 
   was breaking if state title had non-ascii characters. see also 
@@ -44,10 +41,10 @@ Changelog
 ------------------
 
 - Added timezone selection to add site page
-  [pysailor, jensens]
+  [pysailor, yenzenz]
 
 - Added date date and time controlpanel (moved over from plone.app.event).
-  [jensens. thet]
+  [yenzenz. thet]
 
 - Remove DL/DT/DD's from portal messages, portlet templates and others.
   https://github.com/plone/Products.CMFPlone/issues/153
diff --git a/Products/CMFPlone/patches/__init__.py b/Products/CMFPlone/patches/__init__.py
index abde8ab..3499b59 100644
--- a/Products/CMFPlone/patches/__init__.py
+++ b/Products/CMFPlone/patches/__init__.py
@@ -14,6 +14,9 @@
 
 import speed                    # Various caching patches to improve speed
 
+import securemailhost           # SecureMailHost BBB, remove in Plone 5.0
+securemailhost.applyPatches()
+
 import iso8601                  # use `DateTime.ISO8601` for `DateTime.ISO`
 iso8601.applyPatches()
 
diff --git a/Products/CMFPlone/patches/csrf.py b/Products/CMFPlone/patches/csrf.py
index 44690e4..f07a373 100644
--- a/Products/CMFPlone/patches/csrf.py
+++ b/Products/CMFPlone/patches/csrf.py
@@ -28,7 +28,11 @@ def applyPatches():
     MT.deleteLocalRoles = patch(MT.deleteLocalRoles)
     MT.deleteMembers = patch(MT.deleteMembers)
 
-    from Products.CMFCore.MemberDataTool import MemberData as MD
+    try:
+        # XXX CMF 2.3 compatibility, but does it still make sense?
+        from Products.CMFCore.MemberDataTool import MemberAdapter as MD
+    except ImportError:
+        from Products.CMFCore.MemberDataTool import MemberData as MD
     original_setProperties = MD.setProperties
 
     def setProperties(self, properties=None, REQUEST=None, **kw):
@@ -50,7 +54,7 @@ def setProperties(self, properties=None, REQUEST=None, **kw):
         GroupsTool.removePrincipalFromGroup)
 
     from Products.PluggableAuthService.PluggableAuthService import \
-        PluggableAuthService as PAS
+         PluggableAuthService as PAS
     PAS.userFolderAddUser = patch(PAS.userFolderAddUser)
     PAS.userFolderEditUser = patch(PAS.userFolderEditUser)
     PAS.userFolderDelUsers = patch(PAS.userFolderDelUsers)
diff --git a/Products/CMFPlone/patches/iso8601.py b/Products/CMFPlone/patches/iso8601.py
index 1ccf471..785b255 100644
--- a/Products/CMFPlone/patches/iso8601.py
+++ b/Products/CMFPlone/patches/iso8601.py
@@ -1,4 +1,4 @@
-from warnings import warn
+# from warnings import warn
 from DateTime import DateTime
 
 
@@ -6,10 +6,11 @@ def ISO(self):
     """ return ISO8601 instead of ISO format, i.e. including the time zone.
         the latter shouldn't be used anymore.  please see
         http://dev.plone.org/plone/ticket/10140 for more info """
-    warn('Calls to `DateTime.ISO()` should be replaced with '
-         '`DateTime.ISO8601()` to avoid implicit changes to GMT in '
-         'expressions like `DateTime(obj.ModificationTime())`.',
-         DeprecationWarning, stacklevel=2)
+    # Disable the warning until we fixed all of Plone Core.
+    # warn('Calls to `DateTime.ISO()` should be replaced with '
+    #      '`DateTime.ISO8601()` to avoid implicit changes to GMT in '
+    #      'expressions like `DateTime(obj.ModificationTime())`.',
+    #      DeprecationWarning, stacklevel=2)
     return self.ISO8601()
 
 
diff --git a/Products/CMFPlone/patches/securemailhost.py b/Products/CMFPlone/patches/securemailhost.py
new file mode 100644
index 0000000..3280829
--- /dev/null
+++ b/Products/CMFPlone/patches/securemailhost.py
@@ -0,0 +1,168 @@
+"""This module provides backwards compatiblity for products using the
+SecureMailHost API.  It should be removed entirely for Plone 5.0."""
+import sys
+from copy import deepcopy
+from email.Utils import formataddr, getaddresses
+from email.Header import Header
+from email.Message import Message
+from email.MIMEText import MIMEText
+from zope.deprecation import deprecate
+from zope.deferredimport.deferredmodule import (ModuleProxy,
+                                                DeferredAndDeprecated, )
+from AccessControl.Permissions import use_mailhost_services
+from AccessControl.SecurityInfo import ClassSecurityInfo
+from App.class_init import InitializeClass
+from Products.CMFPlone import PloneTool
+from Products.MailHost.MailHost import MailHost, _encode_address_string
+
+
+# The method we care about is now in PloneTool, we allow it to be imported from
+# the original location which has potentially been removed
+try:
+    from Products.SecureMailHost import SecureMailHost
+    smh_module = SecureMailHost
+except ImportError:
+    smh_module = None
+fake_module = ModuleProxy(smh_module or sys.modules[__name__])
+deferred = fake_module.__deferred_definitions__
+deferred['EMAIL_RE'] = DeferredAndDeprecated(
+                'EMAIL_RE',
+                'Products.CMFPlone.PloneTool:EMAIL_RE',
+                'EMAIL_RE has been moved from SecureMailHost, which is no '
+                'longer shipped with Plone.  It can be imported from '
+                'Products.CMFPlone.utils.EMAIL_RE')
+deferred['EMAIL_CUTOFF_RE'] = DeferredAndDeprecated(
+                     'EMAIL_CUTOFF_RE',
+                     'Products.CMFPlone.PloneTool:EMAIL_CUTOFF_RE',
+                     'EMAIL_CUTOFF_RE has been moved from SecureMailHost, '
+                     'which is no longer shipped with Plone.  It can be '
+                     'imported from Products.CMFPlone.utils.EMAIL_CUTOFF_RE')
+
+
+# We can't depend on SecureMailHost, so we have to reimplement
+# a couple methods for BBB
+def email_list_to_string(addr_list, charset='us-ascii'):
+    """SecureMailHost's secureSend can take a list of email addresses
+    in addition to a simple string.  We convert any email input into a
+    properly encoded string."""
+    if addr_list is None:
+        return ''
+    if isinstance(addr_list, basestring):
+        addr_str = addr_list
+    else:
+        # if the list item is a string include it, otherwise assume it's a
+        # (name, address) tuple and turn it into an RFC compliant string
+
+        addresses = (isinstance(a, basestring) and a or formataddr(a)
+                     for a in addr_list)
+        addr_str = ', '.join(str(_encode_address_string(a, charset))
+                             for a in addresses)
+    return addr_str
+
+
+def _addHeaders(message, **kwargs):
+    for key, value in kwargs.iteritems():
+        del message[key]
+        message[key] = value
+
+
+ at deprecate('The MailHost secureSend method is deprecated, '
+           'use send instead.  secureSend will be removed in Plone 5')
+def secureSend(self, message, mto, mfrom, subject='[No Subject]',
+               mcc=None, mbcc=None, subtype='plain', charset='us-ascii',
+               debug=False, **kwargs):
+    """Deprecated method attempting to maintain backwards
+    compatibility for code depending on the SecureMailHost API."""
+    # Convert all our address list inputs
+    mfrom = email_list_to_string(mfrom, charset)
+    mto = email_list_to_string(mto, charset)
+    mcc = email_list_to_string(mcc, charset)
+    mbcc = email_list_to_string(mbcc, charset)
+
+    # Convert to a message for adding headers.  If it's already a
+    # message, copy it to be safe.
+    if not isinstance(message, Message):
+        if isinstance(message, unicode):
+            message.encode(charset)
+        message = MIMEText(message, subtype, charset)
+    else:
+        message = deepcopy(message)
+
+    # Add extra headers
+    _addHeaders(message, Subject=Header(subject, charset),
+                To=mto, Cc=mcc, From=mfrom,
+                **dict((k, Header(v, charset)) for k, v in kwargs.iteritems()))
+
+    all_recipients = [formataddr(pair) for pair in
+                      getaddresses((mto, mcc, mbcc))]
+
+    # Convert message back to string for sending
+    self._send(mfrom, all_recipients, message.as_string(), immediate=True)
+
+ORIG_PERMS = MailHost.__ac_permissions__
+
+msg = ('The %(name)s method of the MailHost is deprecated, '
+       'it is now part of the PloneTool.  Use '
+       'getToolByName(context, "plone_utils").%(name)s instead. '
+       'this method will be removed in '
+       'Plone 5.')
+
+
+def applyPatches():
+    if not hasattr(MailHost, 'secureSend'):
+        pt = PloneTool.PloneTool
+        MailHost.secureSend = secureSend
+        MailHost.validateSingleNormalizedEmailAddress = deprecate(
+            msg % {'name': 'validateSingleNormalizedEmailAddress'})(
+            pt.validateSingleNormalizedEmailAddress.im_func)
+        MailHost.validateSingleEmailAddress = deprecate(
+            msg % {'name': 'validateSingleEmailAddress'})(
+            pt.validateSingleEmailAddress.im_func)
+        MailHost.validateEmailAddresses = deprecate(
+            msg % {'name': 'validateEmailAddresses'})(
+            pt.validateEmailAddresses.im_func)
+        MailHost.emailListToString = deprecate(
+            'The MailHost method emailListToString is deprecated and '
+            'will be removed in Plone 5')(
+                lambda self, *args: email_list_to_string(*args))
+        # set permissions
+        MailHost.security = ClassSecurityInfo()
+        MailHost.security.declareProtected(use_mailhost_services, 'secureSend')
+        MailHost.security.declarePublic('validateSingleNormalizedEmailAddress',
+                                        'validateSingleEmailAddress',
+                                        'validateEmailAddresses',
+                                        'emailListToString')
+        # Merge old permissions with new permissions
+        new_perms = dict(MailHost.__ac_permissions__)
+        updated_perms = dict(ORIG_PERMS)
+        for key, value in new_perms.iteritems():
+            updated_perms[key] = updated_perms[key] + value
+        MailHost.__ac_permissions__ = tuple(updated_perms.iteritems())
+        # apply permisisons settings by reinitializing the class
+        InitializeClass(MailHost)
+        if not smh_module:
+            sys.modules['Products.SecureMailHost'] = fake_module
+        sys.modules['Products.SecureMailHost.SecureMailHost'] = fake_module
+
+
+def removePatches():
+    smh = sys.modules.get('Products.SecureMailHost.SecureMailHost')
+    if type(smh) is ModuleProxy:
+        if not smh_module:
+            del sys.modules['Products.SecureMailHost']
+            del sys.modules['Products.SecureMailHost.SecureMailHost']
+        else:
+            sys.modules['Products.SecureMailHost.SecureMailHost'] = smh_module
+    patched = getattr(MailHost, 'secureSend', None)
+    if patched is not None and patched.im_func is secureSend:
+        del MailHost.secureSend
+        del MailHost.validateSingleNormalizedEmailAddress
+        del MailHost.validateSingleEmailAddress
+        del MailHost.validateEmailAddresses
+        del MailHost.emailListToString
+        del MailHost.secureSend__roles__
+        del MailHost.validateSingleNormalizedEmailAddress__roles__
+        del MailHost.validateSingleEmailAddress__roles__
+        del MailHost.validateEmailAddresses__roles__
+        del MailHost.emailListToString__roles__
+        MailHost.__ac_permissions__ = ORIG_PERMS
diff --git a/Products/CMFPlone/patches/sendmail.py b/Products/CMFPlone/patches/sendmail.py
index 7c46ac2..e6dec2d 100644
--- a/Products/CMFPlone/patches/sendmail.py
+++ b/Products/CMFPlone/patches/sendmail.py
@@ -6,7 +6,6 @@
 
 
 # BBB remove when zope.sendmail 3.8.0 is released.
-# note: looks like 4.0 is next version. when will it happen?
 def catchAllExceptions(func):
     def _catch(*args, **kwargs):
         try:
diff --git a/Products/CMFPlone/patches/unicodeFallbackPatch.py b/Products/CMFPlone/patches/unicodeFallbackPatch.py
index 577108c..520fbd6 100644
--- a/Products/CMFPlone/patches/unicodeFallbackPatch.py
+++ b/Products/CMFPlone/patches/unicodeFallbackPatch.py
@@ -10,10 +10,10 @@
 # Therefor these patches will probably stay here for quite a while.
 
 # import hacks
-from .unicodehacks import new__call__
-from .unicodehacks import _nulljoin
-from .unicodehacks import _unicode_replace
-from .unicodehacks import FasterStringIO
+from unicodehacks import new__call__
+from unicodehacks import _nulljoin
+from unicodehacks import _unicode_replace
+from unicodehacks import FasterStringIO
 
 # import the poor victims of our monkey patches
 from zope.tal import talinterpreter


Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-09-16T21:06:48-05:00
Author: Nathan Van Gheem (vangheem) <vangheem at gmail.com>
Commit: https://github.com/plone/Products.CMFPlone/commit/718efbf65e942bb3495d84f40c8e3d3e9cc4930a

Merge pull request #273 from plone/revert-272-jensens-remove-patches

Revert "Remove some patches"

Files changed:
A Products/CMFPlone/patches/securemailhost.py
M CHANGES.rst
M Products/CMFPlone/patches/__init__.py
M Products/CMFPlone/patches/csrf.py
M Products/CMFPlone/patches/iso8601.py
M Products/CMFPlone/patches/sendmail.py
M Products/CMFPlone/patches/unicodeFallbackPatch.py

diff --git a/CHANGES.rst b/CHANGES.rst
index dc9e341..83be87c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,9 +7,6 @@ Changelog
 
 5.0a3 (unreleased)
 ------------------
-- remove BBB code-patches for securemailhost. warn explicit if DateTime.ISO
-  is called. Remove CMF 2.3 compat. Adresses issue #109.
-  [jensens]
 
 - type controlpanel: Resolved problem with workflow selection form as it 
   was breaking if state title had non-ascii characters. see also 
@@ -44,10 +41,10 @@ Changelog
 ------------------
 
 - Added timezone selection to add site page
-  [pysailor, jensens]
+  [pysailor, yenzenz]
 
 - Added date date and time controlpanel (moved over from plone.app.event).
-  [jensens. thet]
+  [yenzenz. thet]
 
 - Remove DL/DT/DD's from portal messages, portlet templates and others.
   https://github.com/plone/Products.CMFPlone/issues/153
diff --git a/Products/CMFPlone/patches/__init__.py b/Products/CMFPlone/patches/__init__.py
index abde8ab..3499b59 100644
--- a/Products/CMFPlone/patches/__init__.py
+++ b/Products/CMFPlone/patches/__init__.py
@@ -14,6 +14,9 @@
 
 import speed                    # Various caching patches to improve speed
 
+import securemailhost           # SecureMailHost BBB, remove in Plone 5.0
+securemailhost.applyPatches()
+
 import iso8601                  # use `DateTime.ISO8601` for `DateTime.ISO`
 iso8601.applyPatches()
 
diff --git a/Products/CMFPlone/patches/csrf.py b/Products/CMFPlone/patches/csrf.py
index 44690e4..f07a373 100644
--- a/Products/CMFPlone/patches/csrf.py
+++ b/Products/CMFPlone/patches/csrf.py
@@ -28,7 +28,11 @@ def applyPatches():
     MT.deleteLocalRoles = patch(MT.deleteLocalRoles)
     MT.deleteMembers = patch(MT.deleteMembers)
 
-    from Products.CMFCore.MemberDataTool import MemberData as MD
+    try:
+        # XXX CMF 2.3 compatibility, but does it still make sense?
+        from Products.CMFCore.MemberDataTool import MemberAdapter as MD
+    except ImportError:
+        from Products.CMFCore.MemberDataTool import MemberData as MD
     original_setProperties = MD.setProperties
 
     def setProperties(self, properties=None, REQUEST=None, **kw):
@@ -50,7 +54,7 @@ def setProperties(self, properties=None, REQUEST=None, **kw):
         GroupsTool.removePrincipalFromGroup)
 
     from Products.PluggableAuthService.PluggableAuthService import \
-        PluggableAuthService as PAS
+         PluggableAuthService as PAS
     PAS.userFolderAddUser = patch(PAS.userFolderAddUser)
     PAS.userFolderEditUser = patch(PAS.userFolderEditUser)
     PAS.userFolderDelUsers = patch(PAS.userFolderDelUsers)
diff --git a/Products/CMFPlone/patches/iso8601.py b/Products/CMFPlone/patches/iso8601.py
index 1ccf471..785b255 100644
--- a/Products/CMFPlone/patches/iso8601.py
+++ b/Products/CMFPlone/patches/iso8601.py
@@ -1,4 +1,4 @@
-from warnings import warn
+# from warnings import warn
 from DateTime import DateTime
 
 
@@ -6,10 +6,11 @@ def ISO(self):
     """ return ISO8601 instead of ISO format, i.e. including the time zone.
         the latter shouldn't be used anymore.  please see
         http://dev.plone.org/plone/ticket/10140 for more info """
-    warn('Calls to `DateTime.ISO()` should be replaced with '
-         '`DateTime.ISO8601()` to avoid implicit changes to GMT in '
-         'expressions like `DateTime(obj.ModificationTime())`.',
-         DeprecationWarning, stacklevel=2)
+    # Disable the warning until we fixed all of Plone Core.
+    # warn('Calls to `DateTime.ISO()` should be replaced with '
+    #      '`DateTime.ISO8601()` to avoid implicit changes to GMT in '
+    #      'expressions like `DateTime(obj.ModificationTime())`.',
+    #      DeprecationWarning, stacklevel=2)
     return self.ISO8601()
 
 
diff --git a/Products/CMFPlone/patches/securemailhost.py b/Products/CMFPlone/patches/securemailhost.py
new file mode 100644
index 0000000..3280829
--- /dev/null
+++ b/Products/CMFPlone/patches/securemailhost.py
@@ -0,0 +1,168 @@
+"""This module provides backwards compatiblity for products using the
+SecureMailHost API.  It should be removed entirely for Plone 5.0."""
+import sys
+from copy import deepcopy
+from email.Utils import formataddr, getaddresses
+from email.Header import Header
+from email.Message import Message
+from email.MIMEText import MIMEText
+from zope.deprecation import deprecate
+from zope.deferredimport.deferredmodule import (ModuleProxy,
+                                                DeferredAndDeprecated, )
+from AccessControl.Permissions import use_mailhost_services
+from AccessControl.SecurityInfo import ClassSecurityInfo
+from App.class_init import InitializeClass
+from Products.CMFPlone import PloneTool
+from Products.MailHost.MailHost import MailHost, _encode_address_string
+
+
+# The method we care about is now in PloneTool, we allow it to be imported from
+# the original location which has potentially been removed
+try:
+    from Products.SecureMailHost import SecureMailHost
+    smh_module = SecureMailHost
+except ImportError:
+    smh_module = None
+fake_module = ModuleProxy(smh_module or sys.modules[__name__])
+deferred = fake_module.__deferred_definitions__
+deferred['EMAIL_RE'] = DeferredAndDeprecated(
+                'EMAIL_RE',
+                'Products.CMFPlone.PloneTool:EMAIL_RE',
+                'EMAIL_RE has been moved from SecureMailHost, which is no '
+                'longer shipped with Plone.  It can be imported from '
+                'Products.CMFPlone.utils.EMAIL_RE')
+deferred['EMAIL_CUTOFF_RE'] = DeferredAndDeprecated(
+                     'EMAIL_CUTOFF_RE',
+                     'Products.CMFPlone.PloneTool:EMAIL_CUTOFF_RE',
+                     'EMAIL_CUTOFF_RE has been moved from SecureMailHost, '
+                     'which is no longer shipped with Plone.  It can be '
+                     'imported from Products.CMFPlone.utils.EMAIL_CUTOFF_RE')
+
+
+# We can't depend on SecureMailHost, so we have to reimplement
+# a couple methods for BBB
+def email_list_to_string(addr_list, charset='us-ascii'):
+    """SecureMailHost's secureSend can take a list of email addresses
+    in addition to a simple string.  We convert any email input into a
+    properly encoded string."""
+    if addr_list is None:
+        return ''
+    if isinstance(addr_list, basestring):
+        addr_str = addr_list
+    else:
+        # if the list item is a string include it, otherwise assume it's a
+        # (name, address) tuple and turn it into an RFC compliant string
+
+        addresses = (isinstance(a, basestring) and a or formataddr(a)
+                     for a in addr_list)
+        addr_str = ', '.join(str(_encode_address_string(a, charset))
+                             for a in addresses)
+    return addr_str
+
+
+def _addHeaders(message, **kwargs):
+    for key, value in kwargs.iteritems():
+        del message[key]
+        message[key] = value
+
+
+ at deprecate('The MailHost secureSend method is deprecated, '
+           'use send instead.  secureSend will be removed in Plone 5')
+def secureSend(self, message, mto, mfrom, subject='[No Subject]',
+               mcc=None, mbcc=None, subtype='plain', charset='us-ascii',
+               debug=False, **kwargs):
+    """Deprecated method attempting to maintain backwards
+    compatibility for code depending on the SecureMailHost API."""
+    # Convert all our address list inputs
+    mfrom = email_list_to_string(mfrom, charset)
+    mto = email_list_to_string(mto, charset)
+    mcc = email_list_to_string(mcc, charset)
+    mbcc = email_list_to_string(mbcc, charset)
+
+    # Convert to a message for adding headers.  If it's already a
+    # message, copy it to be safe.
+    if not isinstance(message, Message):
+        if isinstance(message, unicode):
+            message.encode(charset)
+        message = MIMEText(message, subtype, charset)
+    else:
+        message = deepcopy(message)
+
+    # Add extra headers
+    _addHeaders(message, Subject=Header(subject, charset),
+                To=mto, Cc=mcc, From=mfrom,
+                **dict((k, Header(v, charset)) for k, v in kwargs.iteritems()))
+
+    all_recipients = [formataddr(pair) for pair in
+                      getaddresses((mto, mcc, mbcc))]
+
+    # Convert message back to string for sending
+    self._send(mfrom, all_recipients, message.as_string(), immediate=True)
+
+ORIG_PERMS = MailHost.__ac_permissions__
+
+msg = ('The %(name)s method of the MailHost is deprecated, '
+       'it is now part of the PloneTool.  Use '
+       'getToolByName(context, "plone_utils").%(name)s instead. '
+       'this method will be removed in '
+       'Plone 5.')
+
+
+def applyPatches():
+    if not hasattr(MailHost, 'secureSend'):
+        pt = PloneTool.PloneTool
+        MailHost.secureSend = secureSend
+        MailHost.validateSingleNormalizedEmailAddress = deprecate(
+            msg % {'name': 'validateSingleNormalizedEmailAddress'})(
+            pt.validateSingleNormalizedEmailAddress.im_func)
+        MailHost.validateSingleEmailAddress = deprecate(
+            msg % {'name': 'validateSingleEmailAddress'})(
+            pt.validateSingleEmailAddress.im_func)
+        MailHost.validateEmailAddresses = deprecate(
+            msg % {'name': 'validateEmailAddresses'})(
+            pt.validateEmailAddresses.im_func)
+        MailHost.emailListToString = deprecate(
+            'The MailHost method emailListToString is deprecated and '
+            'will be removed in Plone 5')(
+                lambda self, *args: email_list_to_string(*args))
+        # set permissions
+        MailHost.security = ClassSecurityInfo()
+        MailHost.security.declareProtected(use_mailhost_services, 'secureSend')
+        MailHost.security.declarePublic('validateSingleNormalizedEmailAddress',
+                                        'validateSingleEmailAddress',
+                                        'validateEmailAddresses',
+                                        'emailListToString')
+        # Merge old permissions with new permissions
+        new_perms = dict(MailHost.__ac_permissions__)
+        updated_perms = dict(ORIG_PERMS)
+        for key, value in new_perms.iteritems():
+            updated_perms[key] = updated_perms[key] + value
+        MailHost.__ac_permissions__ = tuple(updated_perms.iteritems())
+        # apply permisisons settings by reinitializing the class
+        InitializeClass(MailHost)
+        if not smh_module:
+            sys.modules['Products.SecureMailHost'] = fake_module
+        sys.modules['Products.SecureMailHost.SecureMailHost'] = fake_module
+
+
+def removePatches():
+    smh = sys.modules.get('Products.SecureMailHost.SecureMailHost')
+    if type(smh) is ModuleProxy:
+        if not smh_module:
+            del sys.modules['Products.SecureMailHost']
+            del sys.modules['Products.SecureMailHost.SecureMailHost']
+        else:
+            sys.modules['Products.SecureMailHost.SecureMailHost'] = smh_module
+    patched = getattr(MailHost, 'secureSend', None)
+    if patched is not None and patched.im_func is secureSend:
+        del MailHost.secureSend
+        del MailHost.validateSingleNormalizedEmailAddress
+        del MailHost.validateSingleEmailAddress
+        del MailHost.validateEmailAddresses
+        del MailHost.emailListToString
+        del MailHost.secureSend__roles__
+        del MailHost.validateSingleNormalizedEmailAddress__roles__
+        del MailHost.validateSingleEmailAddress__roles__
+        del MailHost.validateEmailAddresses__roles__
+        del MailHost.emailListToString__roles__
+        MailHost.__ac_permissions__ = ORIG_PERMS
diff --git a/Products/CMFPlone/patches/sendmail.py b/Products/CMFPlone/patches/sendmail.py
index 7c46ac2..e6dec2d 100644
--- a/Products/CMFPlone/patches/sendmail.py
+++ b/Products/CMFPlone/patches/sendmail.py
@@ -6,7 +6,6 @@
 
 
 # BBB remove when zope.sendmail 3.8.0 is released.
-# note: looks like 4.0 is next version. when will it happen?
 def catchAllExceptions(func):
     def _catch(*args, **kwargs):
         try:
diff --git a/Products/CMFPlone/patches/unicodeFallbackPatch.py b/Products/CMFPlone/patches/unicodeFallbackPatch.py
index 577108c..520fbd6 100644
--- a/Products/CMFPlone/patches/unicodeFallbackPatch.py
+++ b/Products/CMFPlone/patches/unicodeFallbackPatch.py
@@ -10,10 +10,10 @@
 # Therefor these patches will probably stay here for quite a while.
 
 # import hacks
-from .unicodehacks import new__call__
-from .unicodehacks import _nulljoin
-from .unicodehacks import _unicode_replace
-from .unicodehacks import FasterStringIO
+from unicodehacks import new__call__
+from unicodehacks import _nulljoin
+from unicodehacks import _unicode_replace
+from unicodehacks import FasterStringIO
 
 # import the poor victims of our monkey patches
 from zope.tal import talinterpreter




-------------------------------------------------------------------------------


More information about the Testbot mailing list