[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/mail/ remove SendmailMailer

Benji York benji at zope.com
Fri Jul 29 16:23:00 EDT 2005


Log message for revision 37562:
  remove SendmailMailer
  

Changed:
  U   Zope3/trunk/src/zope/app/mail/configure.zcml
  U   Zope3/trunk/src/zope/app/mail/interfaces.py
  U   Zope3/trunk/src/zope/app/mail/mailer.py
  U   Zope3/trunk/src/zope/app/mail/meta.zcml
  U   Zope3/trunk/src/zope/app/mail/metaconfigure.py
  U   Zope3/trunk/src/zope/app/mail/metadirectives.py
  U   Zope3/trunk/src/zope/app/mail/tests/mail.zcml
  U   Zope3/trunk/src/zope/app/mail/tests/test_directives.py
  U   Zope3/trunk/src/zope/app/mail/tests/test_mailer.py

-=-
Modified: Zope3/trunk/src/zope/app/mail/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/configure.zcml	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/configure.zcml	2005-07-29 20:23:00 UTC (rev 37562)
@@ -10,8 +10,6 @@
              Send out mail with arbitrary from and to addresses"
       />
 
-  <mail:sendmailMailer name="sendmail"/>
-
   <mail:smtpMailer name="smtp" hostname="localhost" port="25" />
 
   <!--

Modified: Zope3/trunk/src/zope/app/mail/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/interfaces.py	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/interfaces.py	2005-07-29 20:23:00 UTC (rev 37562)
@@ -46,9 +46,6 @@
 
     - `ISMTPMailer` sends all messages to a relay host using SMTP
 
-    - `ISendmailMailer` sends messages by calling an external process (usually
-      /usr/lib/sendmail on Unix systems).
-
 - If mail delivery succeeds, an `IMailSentEvent` is dispatched by the mailer.
   If mail delivery fails, no exceptions are raised, but an `IMailErrorEvent` is
   dispatched by the mailer.
@@ -168,15 +165,6 @@
         description=_(u"Password used for optional SMTP authentication."))
 
 
-class ISendmailMailer(IMailer):
-    """A mailer that delivers mail by calling an external process."""
-
-    command = BytesLine(
-        title=_(u"Command"),
-        description=_(u"Command used to send email."),
-        default="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s")
-
-
 class IMailEvent(Interface):
     """Generic mail event."""
 

Modified: Zope3/trunk/src/zope/app/mail/mailer.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/mailer.py	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/mailer.py	2005-07-29 20:23:00 UTC (rev 37562)
@@ -19,30 +19,12 @@
 """
 __docformat__ = 'restructuredtext'
 
-from os import popen
 from smtplib import SMTP
 
 from zope.interface import implements
-from zope.app.mail.interfaces import ISendmailMailer, ISMTPMailer
+from zope.app.mail.interfaces import ISMTPMailer
 
 
-class SendmailMailer(object):
-
-    implements(ISendmailMailer)
-
-    # A hook for unit tests
-    popen = popen
-
-    def __init__(self, command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s"):
-        self.command = command
-
-    def send(self, fromaddr, toaddrs, message):
-        command = self.command % {'from': fromaddr, 'to': " ".join(toaddrs)}
-        f = self.popen(command, "w")
-        f.write(message)
-        f.close()
-
-
 class SMTPMailer(object):
 
     implements(ISMTPMailer)

Modified: Zope3/trunk/src/zope/app/mail/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/meta.zcml	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/meta.zcml	2005-07-29 20:23:00 UTC (rev 37562)
@@ -16,12 +16,6 @@
 
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"
-      name="sendmailMailer" 
-      schema=".metadirectives.ISendmailMailerDirective"
-      handler=".metaconfigure.sendmailMailer" />
-
-  <meta:directive 
-      namespace="http://namespaces.zope.org/mail"
       name="smtpMailer" 
       schema=".metadirectives.ISMTPMailerDirective"
       handler=".metaconfigure.smtpMailer" />

Modified: Zope3/trunk/src/zope/app/mail/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/metaconfigure.py	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/metaconfigure.py	2005-07-29 20:23:00 UTC (rev 37562)
@@ -26,7 +26,7 @@
 from zope.app.mail.delivery import QueuedMailDelivery, DirectMailDelivery
 from zope.app.mail.delivery import QueueProcessorThread
 from zope.app.mail.interfaces import IMailer, IMailDelivery
-from zope.app.mail.mailer import SendmailMailer, SMTPMailer
+from zope.app.mail.mailer import SMTPMailer
 
 
 def _assertPermission(permission, interfaces, component):
@@ -79,15 +79,6 @@
             args = () )
 
 
-def sendmailMailer(_context, name,
-                   command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s"):
-    _context.action(
-        discriminator = ('utility', IMailer, name),
-        callable = handler,
-        args = ('provideUtility',
-                IMailer, SendmailMailer(command), name)
-        )
-
 def smtpMailer(_context, name, hostname="localhost", port="25",
                username=None, password=None):
     _context.action(

Modified: Zope3/trunk/src/zope/app/mail/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/metadirectives.py	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/metadirectives.py	2005-07-29 20:23:00 UTC (rev 37562)
@@ -68,16 +68,6 @@
         required=True)
     
 
-class ISendmailMailerDirective(IMailerDirective):
-    """Registers a new Sendmail mailer."""
-
-    command = ASCII(
-        title=u"Command",
-        description=u"A template command for sending out mail, containing "\
-                    u"%(from)s and %(to)s for respective addresses.",
-        required=False)
-
-
 class ISMTPMailerDirective(IMailerDirective):
     """Registers a new SMTP mailer."""
 

Modified: Zope3/trunk/src/zope/app/mail/tests/mail.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/tests/mail.zcml	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/tests/mail.zcml	2005-07-29 20:23:00 UTC (rev 37562)
@@ -14,10 +14,6 @@
       mailer="test.mailer"
       permission="zope.Public" />
 
-  <mail:sendmailMailer 
-      name="Sendmail"
-      command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s" />
-  
   <mail:smtpMailer 
       name="smtp"
       hostname="localhost"

Modified: Zope3/trunk/src/zope/app/mail/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/tests/test_directives.py	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/tests/test_directives.py	2005-07-29 20:23:00 UTC (rev 37562)
@@ -27,7 +27,7 @@
 
 from zope.app import zapi
 from zope.app.mail.interfaces import \
-     IMailDelivery, IMailer, ISMTPMailer, ISendmailMailer
+     IMailDelivery, IMailer, ISMTPMailer
 from zope.app.mail.delivery import QueueProcessorThread
 from zope.app.mail import delivery
 from zope.app.testing import ztapi
@@ -89,10 +89,6 @@
         self.assertEqual('DirectMailDelivery', delivery.__class__.__name__)
         self.assert_(self.testMailer is delivery.mailer)
 
-    def testSendmailMailer(self):
-        mailer = zapi.getUtility(IMailer, "Sendmail")
-        self.assert_(ISendmailMailer.providedBy(mailer))
-
     def testSMTPMailer(self):
         mailer = zapi.getUtility(IMailer, "smtp")
         self.assert_(ISMTPMailer.providedBy(mailer))

Modified: Zope3/trunk/src/zope/app/mail/tests/test_mailer.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/tests/test_mailer.py	2005-07-29 20:18:00 UTC (rev 37561)
+++ Zope3/trunk/src/zope/app/mail/tests/test_mailer.py	2005-07-29 20:23:00 UTC (rev 37562)
@@ -19,39 +19,9 @@
 import unittest
 from StringIO import StringIO
 from zope.interface.verify import verifyObject
-from zope.app.mail.interfaces import ISendmailMailer, ISMTPMailer
+from zope.app.mail.interfaces import ISMTPMailer
 
 
-class TestSendmailMailer(unittest.TestCase):
-
-    def setUp(self):
-        from zope.app.mail.mailer import SendmailMailer
-
-        class ShtringIO(StringIO):
-            def close(self):
-                pass
-        self.input = ShtringIO()
-        def popen(cmd, mode):
-            self.cmd_arg = cmd
-            self.mode_arg = mode
-            return self.input
-        self.mailer = SendmailMailer()
-        self.mailer.popen = popen
-
-    def test_interface(self):
-        verifyObject(ISendmailMailer, self.mailer)
-
-    def test_send(self):
-        msgtext = 'Headers: headers\n\nbodybodybody\n-- \nsig\n'
-        self.mailer.send('me at example.com',
-                         ('you at example.com', 'him at example.com'),
-                         msgtext)
-        self.assertEquals(self.input.getvalue(), msgtext)
-        self.assertEquals(self.cmd_arg, "/usr/lib/sendmail -oem -oi"
-                          " -f me at example.com you at example.com him at example.com")
-        self.assertEquals(self.mode_arg, "w")
-
-
 class TestSMTPMailer(unittest.TestCase):
 
     def setUp(self, port=None):
@@ -123,7 +93,6 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(TestSendmailMailer))
     suite.addTest(unittest.makeSuite(TestSMTPMailer))
     return suite
 



More information about the Zope3-Checkins mailing list