summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Vagelpohl <jens@netz.ooo>2006-02-22 13:29:58 +0000
committerJens Vagelpohl <jens@netz.ooo>2006-02-22 13:29:58 +0000
commit74621cae16b21dd4d9eeb5b378b3961da7e28a83 (patch)
treebe1aac0acd7e097ee544294c664b7bcff57e3fd5
parenta69cf07fc69759c6d0890eec2a3eb6e2110cb8a1 (diff)
downloadMaildropHost-74621cae16b21dd4d9eeb5b378b3961da7e28a83.zip
MaildropHost-74621cae16b21dd4d9eeb5b378b3961da7e28a83.tar.gz
- Change the way the email objects are constructed to avoid
problems with a loss of an instance attribute seen before.
-rw-r--r--CHANGES.txt7
-rw-r--r--MaildropHost.py12
-rw-r--r--tests/test_MaildropHost.py16
3 files changed, 16 insertions, 19 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index ea7f415..120657f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,12 +1,11 @@
MaildropHost version and change information
- After MaildropHost 1.14
+ MaildropHost 1.15 (2006/02/22)
* Bugs fixed
- - After seeing an unexplained attribute loss on an instance at
- a customer site and the resulting breakage, be a little more
- defensive when getting attributes like the email class.
+ - Change the way the email objects are constructed to avoid
+ problems with a loss of an instance attribute seen before.
- Document the fact that Windows is not supported for the
maildrop daemon script.
diff --git a/MaildropHost.py b/MaildropHost.py
index b28b554..0f36bb9 100644
--- a/MaildropHost.py
+++ b/MaildropHost.py
@@ -124,7 +124,6 @@ class MaildropHost(MailHost):
self.id = id
self.title = title
self._transactional = True
- self._email_class = TransactionalEmail
security.declareProtected('Change configuration', 'manage_makeChanges')
@@ -138,11 +137,6 @@ class MaildropHost(MailHost):
self.title = title
self._transactional = not not transactional
- if self._transactional:
- self._email_class = TransactionalEmail
- else:
- self._email_class = Email
-
if REQUEST is not None:
msg = 'MaildropHost "%s" updated' % self.id
return self.manage_main(manage_tabs_message=msg)
@@ -159,8 +153,10 @@ class MaildropHost(MailHost):
if self.add_messageid:
body = 'Message-Id: %s\n%s' % (make_msgid(), body)
- email_klass = getattr(self, '_email_class', TransactionalEmail)
- email = email_klass(m_from, m_to, body)
+ if self.isTransactional():
+ email = TransactionalEmail(m_from, m_to, body)
+ else:
+ email = Email(m_from, m_to, body)
return email.send()
diff --git a/tests/test_MaildropHost.py b/tests/test_MaildropHost.py
index 40d7a88..7ac8e3c 100644
--- a/tests/test_MaildropHost.py
+++ b/tests/test_MaildropHost.py
@@ -22,12 +22,6 @@ Zope2.startup()
# MaildropHost package imports
from Products.MaildropHost.MaildropHost import MaildropHost
-class FakeEmail:
- def __init__(self, mfrom, mto, body):
- self.body = body
-
- def send(self):
- return self.body
class MaildropHostTests(TestCase):
@@ -46,7 +40,13 @@ class MaildropHostTests(TestCase):
self.assertEquals(self.mdh.isTransactional(), False)
def test_add_messageid(self):
- self.mdh._email_class = FakeEmail
+ from Products.MaildropHost.MaildropHost import TransactionalEmail
+
+ def fake_send(email):
+ return email.body
+
+ old_send = TransactionalEmail.send
+ TransactionalEmail.send = fake_send
self.mdh.add_messageid = True
massaged_body = self.mdh._send('sender', 'receiver', 'body')
@@ -56,6 +56,8 @@ class MaildropHostTests(TestCase):
unmassaged_body = self.mdh._send('sender', 'receiver', 'body')
self.failIf(unmassaged_body.lower().startswith('message-id'))
+ TransactionalEmail.send = old_send
+
def test_suite():
return TestSuite((