[Zope3-checkins] CVS: Zope3/src/zope/app/mail - delivery.py:1.1 interfaces.py:1.1 configure.zcml:1.8 event.py:1.4 maildir.py:1.4 mailer.py:1.6 meta.zcml:1.4 metaconfigure.py:1.6 metadirectives.py:1.4 service.py:NONE

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Mar 3 04:16:13 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/mail
In directory cvs.zope.org:/tmp/cvs-serv25620/src/zope/app/mail

Modified Files:
	configure.zcml event.py maildir.py mailer.py meta.zcml 
	metaconfigure.py metadirectives.py 
Added Files:
	delivery.py interfaces.py 
Removed Files:
	service.py 
Log Message:


- Renamed MailService to MailDelivery



- Made MailDelivery a utility



- Made Mailer a utility. Removed custom registry.




=== Added File Zope3/src/zope/app/mail/delivery.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Mail Delivery utility implementation

This module contains various implementations of MailDeliverys.

$Id: delivery.py,v 1.1 2004/03/03 09:15:41 srichter Exp $
"""
import rfc822
import threading
import logging

from os import unlink, getpid
from cStringIO import StringIO
from random import randrange
from time import strftime
from socket import gethostname

from zope.interface import implements
from zope.app.mail.interfaces import IDirectMailDelivery, IQueuedMailDelivery
from zope.app.mail.maildir import Maildir
from transaction.interfaces import IDataManager
from transaction import get_transaction
from transaction.util import NoSavepointSupportRollback

class MailDataManager(object):

    implements(IDataManager)

    def __init__(self, callable, args=(), onAbort=None):
        self.callable = callable
        self.args = args
        self.onAbort = onAbort

    def prepare(self, transaction):
        pass

    def abort(self, transaction):
        if self.onAbort:
            self.onAbort()

    def commit(self, transaction):
        self.callable(*self.args)

    def savepoint(self, transaction):
        return NoSavepointSupportRollback(self)


class AbstractMailDelivery(object):

    def newMessageId(self):
        """Generates a new message ID according to RFC 2822 rules"""
        randmax = 0x7fffffff
        left_part = '%s.%d.%d' % (strftime('%Y%m%d%H%M%S'),
                                  getpid(),
                                  randrange(0, randmax))
        return "%s@%s" % (left_part, gethostname())

    def send(self, fromaddr, toaddrs, message):
        parser = rfc822.Message(StringIO(message))
        messageid = parser.getheader('Message-Id')
        if messageid:
            if not messageid.startswith('<') or not messageid.endswith('>'):
                raise ValueError('Malformed Message-Id header')
            messageid = messageid[1:-1]
        else:
            messageid = self.newMessageId()
            message = 'Message-Id: <%s>\n%s' % (messageid, message)
        get_transaction().join(
            self.createDataManager(fromaddr, toaddrs, message))
        return messageid


class DirectMailDelivery(AbstractMailDelivery):
    __doc__ = IDirectMailDelivery.__doc__

    implements(IDirectMailDelivery)

    def __init__(self, mailer):
        self.mailer = mailer

    def createDataManager(self, fromaddr, toaddrs, message):
        return MailDataManager(self.mailer.send,
                               args=(fromaddr, toaddrs, message))


class QueuedMailDelivery(AbstractMailDelivery):
    __doc__ = IQueuedMailDelivery.__doc__

    implements(IQueuedMailDelivery)

    def __init__(self, queuePath):
        self._queuePath = queuePath

    queuePath = property(lambda self: self._queuePath)

    def createDataManager(self, fromaddr, toaddrs, message):
        maildir = Maildir(self.queuePath, True)
        msg = maildir.newMessage()
        msg.write('X-Zope-From: %s\n' % fromaddr)
        msg.write('X-Zope-To: %s\n' % ", ".join(toaddrs))
        msg.write(message)
        return MailDataManager(msg.commit, onAbort=msg.abort)

class QueueProcessorThread(threading.Thread):
    """This thread is started at configuration time from the
    mail:queuedDelivery directive handler.
    """
    log = logging.getLogger("QueueProcessorThread")
    __stopped = False

    def __init__(self):
        threading.Thread.__init__(self)
        self.__event = threading.Event()

    def setMaildir(self, maildir):
        """Set the maildir.

        This method is used just to provide a maildir stubs ."""
        self.maildir = maildir

    def setQueuePath(self, path):
        self.maildir = Maildir(path, True)

    def setMailer(self, mailer):
        self.mailer = mailer

    def _parseMessage(self, message):
        """Extract fromaddr and toaddrs from the first two lines of
        the message.

        Returns a fromaddr string, a toaddrs tuple and the message
        string.
        """

        fromaddr = ""
        toaddrs = ()
        rest = ""

        try:
            first, second, rest = message.split('\n', 2)
        except ValueError:
            return fromaddr, toaddrs, message

        if first.startswith("X-Zope-From: "):
            i = len("X-Zope-From: ")
            fromaddr = first[i:]

        if second.startswith("X-Zope-To: "):
            i = len("X-Zope-To: ")
            toaddrs = tuple(second[i:].split(", "))

        return fromaddr, toaddrs, rest

    def run(self, forever=True):

        while True:
            for filename in self.maildir:
                try:
                    file = open(filename)
                    message = file.read()
                    file.close()
                    fromaddr, toaddrs, message = self._parseMessage(message)
                    self.mailer.send(fromaddr, toaddrs, message)
                    unlink(filename)
                    # XXX maybe log the Message-Id of the message sent
                    self.log.info("Mail from %s to %s sent.",
                                  fromaddr, ", ".join(toaddrs))
                    # Blanket except because we don't want this thread to ever die
                except:
                    # XXX maybe throw away erroring messages here?
                    # XXX: Note that fromaddr and toaddr is not available
                    #      here! This needs fixing. (SR)
                    self.log.error("Error while sending mail from %s to %s.",
                                   fromaddr, ", ".join(toaddrs), exc_info=1)
            else:
                if forever:
                    self.__event.wait(3)
                    if self.__stopped:
                        return

            # A testing plug
            if not forever:
                break

    def stop(self):
        self.__stopped = True
        self.__event.set()


=== Added File Zope3/src/zope/app/mail/interfaces.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Mail service interfaces

Email sending from Zope 3 applications works as follows:

- A Zope 3 application locates a mail delivery utility ('IMailDelivery') and
  feeds a message to it. It gets back a unique message ID so it can keep
  track of the message by subscribing to 'IMailEvent' events.

- The utility registers with the transaction system to make sure the
  message is only sent when the transaction commits successfully.  (Among
  other things this avoids duplicate messages on 'ConflictErrors'.)

- If the delivery utility is a 'IQueuedMailDelivery', it puts the message into a
  queue (a Maildir mailbox in the file system). A separate process or thread
  ('IMailQueueProcessor') watches the queue and delivers messages
  asynchronously. Since the queue is located in the file system, it survives
  Zope restarts or crashes and the mail is not lost.  The queue processor
  can implement batching to keep the server load low.

- If the delivery utility is a IDirectMailDelivery, it delivers messages
  synchronously during the transaction commit.  This is not a very good idea,
  as it makes the user wait.  Note that transaction commits must not fail,
  but that is not a problem, because mail delivery problems dispatch an
  event instead of raising an exception.

  XXX and there's the problem -- sending events causes unknown code to be
  executed during the transaction commit phase.  There should be a way to
  start a new transaction for event processing after this one is commited.

- An 'IMailQueueProcessor' or 'IDirectMailDelivery' actually delivers the
  messages by using a mailer ('IMailer') component that encapsulates the
  delivery process.  There are currently two mailers:

    - '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.

$Id: interfaces.py,v 1.1 2004/03/03 09:15:41 srichter Exp $
"""
from zope.interface import Interface, Attribute
from zope.schema import Object, TextLine, Int, Password, BytesLine

from zope.app.event.interfaces import IEvent
from zope.app.i18n import ZopeMessageIDFactory as _


class IMailDelivery(Interface):
    """A mail delivery utility allows someone to send an email to a group of
    people."""

    def send(fromaddr, toaddrs, message):
        """Sends an email message.

        'fromaddr' is the sender address (byte string),

        'toaddrs' is a sequence of recipient addresses (byte strings).

        'message' is a byte string that contains both headers and body
        formatted according to RFC 2822.  If it does not contain a Message-Id
        header, it will be generated and added automatically.

        Returns the message ID.

        You can subscribe to IMailEvent events for notification about problems
        or successful delivery.

        Messages are actually sent during transaction commit.
        """


class IDirectMailDelivery(IMailDelivery):
    """A mail delivery utility that delivers messages synchronously during
    transaction commit.

    Not useful for production use, but simpler to set up and use.
    """

    mailer = Attribute("IMailer that is used for message delivery")


class IQueuedMailDelivery(IMailDelivery):
    """A mail delivery utility that puts all messages into a queue in the
    filesystem.

    Messages will be delivered asynchronously by a separate component.
    """

    queuePath = TextLine(
        title=_(u"Queue path"),
        description=_(u"Pathname of the directory used to queue mail."))


class IMailQueueProcessor(Interface):
    """A mail queue processor that delivers queueud messages asynchronously.
    """

    queuePath = TextLine(
        title=_(u"Queue Path"),
        description=_(u"Pathname of the directory used to queue mail."))

    pollingInterval = Int(
        title=_(u"Polling Interval"),
        description=_(u"How often the queue is checked for new messages"
                       " (in milliseconds)"),
        default=5000)

    mailer = Attribute("IMailer that is used for message delivery")


class IMailer(Interface):
    """Mailer handles syncrhonous mail delivery."""

    def send(fromaddr, toaddrs, message):
        """Sends an email message.

        'fromaddr' is the sender address (unicode string),

        'toaddrs' is a sequence of recipient addresses (unicode strings).

        'message' contains both headers and body formatted according to RFC
        2822.  It should contain at least Date, From, To, and Message-Id
        headers.

        Messages are sent immediatelly.

        Dispatches an IMailSentEvent on successful delivery, otherwise an
        IMailErrorEvent.
        """


class ISMTPMailer(IMailer):
    """A mailer that delivers mail to a relay host via SMTP."""

    hostname = TextLine(
        title=_(u"Hostname"),
        description=_(u"Name of server to be used as SMTP server."))

    port = Int(
        title=_(u"Port"),
        description=_(u"Port of SMTP service"),
        default=25)

    username = TextLine(
        title=_(u"Username"),
        description=_(u"Username used for optional SMTP authentication."))

    password = Password(
        title=_(u"Password"),
        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(IEvent):
    """Generic mail event."""

    messageId = Attribute("Message id according to RFC 2822")


class IMailSentEvent(IMailEvent):
    """Event that is fired when a message is succesfully sent.

    This does not mean that all the recipients have received it, it only
    means that the message left this system successfully.  It is possible
    that a bounce message will arrive later from some remote mail server.
    """


class IMailErrorEvent(IMailEvent):
    """Event that is fired when a message cannot be delivered."""

    errorMessage = Attribute("Error message")



class IMaildirFactory(Interface):

    def __call__(dirname, create=False):
        """Opens a Maildir folder at a given filesystem path.

        If 'create' is True, the folder will be created when it does not
        exist.  If 'create' is False and the folder does not exist, an
        exception (OSError) will be raised.

        If path points to a file or an existing directory that is not a
        valid Maildir folder, an exception is raised regardless of the
        'create' argument.
        """


class IMaildir(Interface):
    """Read/write access to Maildir folders.

    See http://www.qmail.org/man/man5/maildir.html for detailed format
    description.
    """

    def __iter__():
        """Returns an iterator over the pathnames of messages in this folder.
        """

    def newMessage():
        """Creates a new message in the maildir.

        Returns a file-like object for a new file in the 'tmp' subdirectory
        of the Maildir.  After writing message contents to it, call the
        commit() or abort() method on it.

        The returned object implements IMaildirMessageWriter.
        """


class IMaildirMessageWriter(Interface):
    """A file-like object to a new message in a Maildir."""

    def write(str):
        """Writes a string to the file.

        There is no return value. Due to buffering, the string may not actually
        show up in the file until the commit() method is called.
        """

    def writelines(sequence):
        """Writes a sequence of strings to the file.

        The sequence can be any iterable object producing strings, typically a
        list of strings. There is no return value.  'writelines' does not add
        any line separators.
        """

    def commit():
        """Commits the new message using the Maildir protocol.

        First, the message file is flushed, closed, then it is moved from
        'tmp' into 'new' subdirectory of the maildir.

        Calling commit() more than once is allowed.
        """

    def abort():
        """Aborts the new message.

        The message file is closed and removed from the 'tmp' subdirectory
        of the maildir.

        Calling abort() more than once is allowed.
        """


=== Zope3/src/zope/app/mail/configure.zcml 1.7 => 1.8 ===
--- Zope3/src/zope/app/mail/configure.zcml:1.7	Wed Aug 20 14:21:11 2003
+++ Zope3/src/zope/app/mail/configure.zcml	Wed Mar  3 04:15:41 2004
@@ -4,10 +4,6 @@
    i18n_domain="zope"
    >
 
-  <serviceType
-      id="Mail"
-      interface="zope.app.interfaces.mail.IMailService"/>
-
   <permission
       id="zope.SendMail" 
       title="[send-mail-permission]


=== Zope3/src/zope/app/mail/event.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/mail/event.py:1.3	Mon Jun 23 11:45:39 2003
+++ Zope3/src/zope/app/mail/event.py	Wed Mar  3 04:15:41 2004
@@ -15,13 +15,12 @@
 
 $Id$
 """
-from zope.app.interfaces.mail import IMailSentEvent, IMailErrorEvent
 from zope.interface import implements
 
-__metaclass__ = type
+from zope.app.mail.interfaces import IMailSentEvent, IMailErrorEvent
 
 
-class MailSentEvent:
+class MailSentEvent(object):
     __doc__ = IMailSentEvent.__doc__
 
     implements(IMailSentEvent)
@@ -30,7 +29,7 @@
         self.messageId = messageId
 
 
-class MailErrorEvent:
+class MailErrorEvent(object):
     __doc__ = IMailErrorEvent.__doc__
 
     implements(IMailErrorEvent)


=== Zope3/src/zope/app/mail/maildir.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/mail/maildir.py:1.3	Tue Jul  1 05:46:52 2003
+++ Zope3/src/zope/app/mail/maildir.py	Wed Mar  3 04:15:41 2004
@@ -17,17 +17,16 @@
 
 $Id$
 """
-
 import os
 import socket
 import time
+
 from zope.interface import implements, classProvides
-from zope.app.interfaces.mail import IMaildirFactory, IMaildir
-from zope.app.interfaces.mail import IMaildirMessageWriter
 
-__metaclass__ = type
+from zope.app.mail.interfaces import \
+     IMaildirFactory, IMaildir, IMaildirMessageWriter
 
-class Maildir:
+class Maildir(object):
     """See zope.app.interfaces.mail.IMaildir"""
 
     classProvides(IMaildirFactory)
@@ -96,7 +95,7 @@
         return MaildirMessageWriter(filename, join(subdir_new, unique))
 
 
-class MaildirMessageWriter:
+class MaildirMessageWriter(object):
     """See zope.app.interfaces.mail.IMaildirMessageWriter"""
 
     implements(IMaildirMessageWriter)


=== Zope3/src/zope/app/mail/mailer.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/mail/mailer.py:1.5	Mon Jun 23 11:45:39 2003
+++ Zope3/src/zope/app/mail/mailer.py	Wed Mar  3 04:15:41 2004
@@ -17,15 +17,14 @@
 
 $Id$
 """
-
-from zope.interface import implements
-from zope.app.interfaces.mail import ISendmailMailer, ISMTPMailer
 from os import popen
 from smtplib import SMTP
 
-__metaclass__ = type
+from zope.interface import implements
+from zope.app.mail.interfaces import ISendmailMailer, ISMTPMailer
+
 
-class SendmailMailer:
+class SendmailMailer(object):
 
     implements(ISendmailMailer)
 
@@ -41,7 +40,7 @@
         f.write(message)
         f.close()
 
-class SMTPMailer:
+class SMTPMailer(object):
 
     implements(ISMTPMailer)
 


=== Zope3/src/zope/app/mail/meta.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/mail/meta.zcml:1.3	Sat Aug  2 08:30:24 2003
+++ Zope3/src/zope/app/mail/meta.zcml	Wed Mar  3 04:15:41 2004
@@ -4,15 +4,15 @@
 
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"
-      name="queuedService" 
-      schema=".metadirectives.IQueuedServiceDirective"
-      handler=".metaconfigure.queuedService" />
+      name="queuedDelivery" 
+      schema=".metadirectives.IQueuedDeliveryDirective"
+      handler=".metaconfigure.queuedDelivery" />
 
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"
-      name="directService" 
-      schema=".metadirectives.IDirectServiceDirective"
-      handler=".metaconfigure.directService" />
+      name="directDelivery" 
+      schema=".metadirectives.IDirectDeliveryDirective"
+      handler=".metaconfigure.directDelivery" />
 
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"


=== Zope3/src/zope/app/mail/metaconfigure.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/mail/metaconfigure.py:1.5	Sun Aug 17 02:07:13 2003
+++ Zope3/src/zope/app/mail/metaconfigure.py	Wed Mar  3 04:15:41 2004
@@ -16,88 +16,84 @@
 $Id$
 """
 from zope.configuration.exceptions import ConfigurationError
-from zope.app.component.metaconfigure import provideService
-from zope.app.mail.service import QueuedMailService, DirectMailService
-from zope.app.mail.service import QueueProcessorThread
-from zope.app.mail.mailer import SendmailMailer, SMTPMailer
 
+from zope.security.checker import InterfaceChecker, CheckerPublic
+
+from zope.app import zapi
+from zope.app.component.metaconfigure import handler, proxify, PublicPermission
+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
 
-def queuedService(_context, permission, queuePath, mailer, name="Mail"):
 
-    def createQueuedService():
-        component = QueuedMailService(queuePath)
-        provideService(name, component, permission)
+def _assertPermission(permission, interfaces, component):
+    if permission is not None:
+        if permission == PublicPermission:
+            permission = CheckerPublic
+        checker = InterfaceChecker(interfaces, permission)
+
+    return proxify(component, checker)
+    
+
+def queuedDelivery(_context, permission, queuePath, mailer, name=None):
+
+    def createQueuedDelivery():
+        delivery = QueuedMailDelivery(queuePath)
+        delivery = _assertPermission(permission, IMailDelivery, delivery)
+
+        utilities = zapi.getService(None, 'Utilities')
+        handler('Utilities', 'provideUtility', IMailDelivery, delivery, name)
+
+        mailerObject = zapi.queryUtility(None, IMailer, name=mailer)
+        if mailerObject is None:
+            raise ConfigurationError("Mailer %r is not defined" %mailer)
 
         thread = QueueProcessorThread()
-        thread.setMailer(getMailer(mailer))
+        thread.setMailer(mailerObject)
         thread.setQueuePath(queuePath)
         thread.setDaemon(True)
         thread.start()
 
     _context.action(
-            discriminator = ('service', name),
-            callable = createQueuedService,
+            discriminator = ('delivery', name),
+            callable = createQueuedDelivery,
             args = () )
 
-def directService(_context, permission, mailer, name="Mail"):
 
-    def makeService():
-        mailer_component = queryMailer(mailer)
-        if mailer_component is None:
-            raise ConfigurationError("Mailer %r is not defined" % mailer)
-        component = DirectMailService(mailer_component)
-        provideService(name, component, permission)
+def directDelivery(_context, permission, mailer, name=None):
+
+    def createDirectDelivery():
+        mailerObject = zapi.queryUtility(None, IMailer, name=mailer)
+        if mailerObject is None:
+            raise ConfigurationError("Mailer %r is not defined" %mailer)
+
+        delivery = DirectMailDelivery(mailerObject)
+        delivery = _assertPermission(permission, IMailDelivery, delivery)
+
+        utilities = zapi.getService(None, 'Utilities')
+        handler('Utilities', 'provideUtility', IMailDelivery, delivery, name)
 
     _context.action(
-            discriminator = ('service', name),
-            callable = makeService,
+            discriminator = ('utility', IMailDelivery, name),
+            callable = createDirectDelivery,
             args = () )
 
 
-def sendmailMailer(_context, id,
+def sendmailMailer(_context, name,
                    command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s"):
     _context.action(
-        discriminator=('mailer', id),
-        callable=provideMailer,
-        args=(id, SendmailMailer(command)) )
-
+        discriminator = ('utility', IMailer, name),
+        callable = handler,
+        args = ('Utilities', 'provideUtility',
+                IMailer, SendmailMailer(command), name)
+        )
 
-def smtpMailer(_context, id, hostname="localhost", port="25",
+def smtpMailer(_context, name, hostname="localhost", port="25",
                username=None, password=None):
     _context.action(
-        discriminator=('mailer', id),
-        callable=provideMailer,
-        args=(id, SMTPMailer(hostname, port, username, password)) )
-
-# Example of mailer configuration:
-#
-#   def smtp(_context, id, hostname, port):
-#       component = SMTPMailer(hostname, port)
-#       if queryMailer(id) is not None:
-#           raise ConfigurationError("Redefinition of mailer %r" % id)
-#       provideMailer(id, component)
-#       return []
-#
-# or is it better to make mailer registration an Action?  But that won't work,
-# because queryMailer will get called during directive processing, before any
-# actions are run.
-
-
-mailerRegistry = {}
-queryMailer = mailerRegistry.get
-provideMailer = mailerRegistry.__setitem__
-
-def getMailer(mailer):
-    result = queryMailer(mailer)
-    if result is None:
-        raise ConfigurationError("Mailer lookup failed")
-    return result
-
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
-try:
-    from zope.testing.cleanup import addCleanUp
-except ImportError:
-    pass
-else:
-    addCleanUp(mailerRegistry.clear)
-    del addCleanUp
+        discriminator = ('utility', IMailer, name),
+        callable = handler,
+        args = ('Utilities', 'provideUtility',
+                IMailer, SMTPMailer(hostname, port, username, password), name)
+        )


=== Zope3/src/zope/app/mail/metadirectives.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/mail/metadirectives.py:1.3	Wed Dec 17 05:20:49 2003
+++ Zope3/src/zope/app/mail/metadirectives.py	Wed Mar  3 04:15:41 2004
@@ -19,13 +19,13 @@
 from zope.interface import Interface
 from zope.schema import TextLine, Bytes, ASCII, BytesLine, Int
 
-class IServiceDirective(Interface):
+class IDeliveryDirective(Interface):
     """This abstract directive describes a generic mail service
     registration."""
     
     name = TextLine(
         title=u"Name",
-        description=u'Specifies the Service name of the mail service. '\
+        description=u'Specifies the Delivery name of the mail service. '\
                     u'The default is "Mail".',
         default=u"Mail",
         required=False)
@@ -41,7 +41,7 @@
         required=True)
 
 
-class IQueuedServiceDirective(IServiceDirective):
+class IQueuedDeliveryDirective(IDeliveryDirective):
     """This directive creates and registers a global queued mail service. It
     should be only called once during startup."""
 
@@ -51,7 +51,7 @@
         required=True)
 
 
-class IDirectServiceDirective(IServiceDirective):
+class IDirectDeliveryDirective(IDeliveryDirective):
     """This directive creates and registers a global direct mail service. It
     should be only called once during startup."""
 
@@ -59,9 +59,9 @@
 class IMailerDirective(Interface):
     """A generic directive registering a mailer for the mail service."""
 
-    id = TextLine(
-        title=u"Id",
-        description=u"Id of the Mailer.",
+    name = TextLine(
+        title=u"Name",
+        description=u"Name of the Mailer.",
         required=True)
     
 

=== Removed File Zope3/src/zope/app/mail/service.py ===




More information about the Zope3-Checkins mailing list