[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/sendmail/ Reduce module clutter a bit by moving directive schemas and handlers into one module

Philipp von Weitershausen philikon at philikon.de
Wed Apr 19 09:35:20 EDT 2006


Log message for revision 67127:
  Reduce module clutter a bit by moving directive schemas and handlers into one module
  (following a recent convention from other packages)
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/sendmail/meta.zcml
  D   Zope3/branches/jim-adapter/src/zope/sendmail/metaconfigure.py
  D   Zope3/branches/jim-adapter/src/zope/sendmail/metadirectives.py
  A   Zope3/branches/jim-adapter/src/zope/sendmail/zcml.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/sendmail/meta.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/sendmail/meta.zcml	2006-04-19 13:16:35 UTC (rev 67126)
+++ Zope3/branches/jim-adapter/src/zope/sendmail/meta.zcml	2006-04-19 13:35:20 UTC (rev 67127)
@@ -5,19 +5,22 @@
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"
       name="queuedDelivery" 
-      schema=".metadirectives.IQueuedDeliveryDirective"
-      handler=".metaconfigure.queuedDelivery" />
+      schema=".zcml.IQueuedDeliveryDirective"
+      handler=".zcml.queuedDelivery"
+      />
 
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"
       name="directDelivery" 
-      schema=".metadirectives.IDirectDeliveryDirective"
-      handler=".metaconfigure.directDelivery" />
+      schema=".zcml.IDirectDeliveryDirective"
+      handler=".zcml.directDelivery"
+      />
 
   <meta:directive 
       namespace="http://namespaces.zope.org/mail"
       name="smtpMailer" 
-      schema=".metadirectives.ISMTPMailerDirective"
-      handler=".metaconfigure.smtpMailer" />
+      schema=".zcml.ISMTPMailerDirective"
+      handler=".zcml.smtpMailer"
+      />
 
 </configure>

Deleted: Zope3/branches/jim-adapter/src/zope/sendmail/metaconfigure.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/sendmail/metaconfigure.py	2006-04-19 13:16:35 UTC (rev 67126)
+++ Zope3/branches/jim-adapter/src/zope/sendmail/metaconfigure.py	2006-04-19 13:35:20 UTC (rev 67127)
@@ -1,88 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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 ZCML Namespace handler
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.component import queryUtility
-from zope.component.zcml import handler, proxify, PublicPermission
-from zope.configuration.exceptions import ConfigurationError
-from zope.security.checker import InterfaceChecker, CheckerPublic
-
-from zope.sendmail.delivery import QueuedMailDelivery, DirectMailDelivery
-from zope.sendmail.delivery import QueueProcessorThread
-from zope.sendmail.interfaces import IMailer, IMailDelivery
-from zope.sendmail.mailer import SMTPMailer
-
-
-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="Mail"):
-
-    def createQueuedDelivery():
-        delivery = QueuedMailDelivery(queuePath)
-        delivery = _assertPermission(permission, IMailDelivery, delivery)
-
-        handler('registerUtility', delivery, IMailDelivery, name)
-
-        mailerObject = queryUtility(IMailer, mailer)
-        if mailerObject is None:
-            raise ConfigurationError("Mailer %r is not defined" %mailer)
-
-        thread = QueueProcessorThread()
-        thread.setMailer(mailerObject)
-        thread.setQueuePath(queuePath)
-        thread.start()
-
-    _context.action(
-            discriminator = ('delivery', name),
-            callable = createQueuedDelivery,
-            args = () )
-
-
-def directDelivery(_context, permission, mailer, name="Mail"):
-
-    def createDirectDelivery():
-        mailerObject = queryUtility(IMailer, mailer)
-        if mailerObject is None:
-            raise ConfigurationError("Mailer %r is not defined" %mailer)
-
-        delivery = DirectMailDelivery(mailerObject)
-        delivery = _assertPermission(permission, IMailDelivery, delivery)
-
-        handler('registerUtility', delivery, IMailDelivery, name)
-
-    _context.action(
-            discriminator = ('utility', IMailDelivery, name),
-            callable = createDirectDelivery,
-            args = () )
-
-
-def smtpMailer(_context, name, hostname="localhost", port="25",
-               username=None, password=None):
-    _context.action(
-        discriminator = ('utility', IMailer, name),
-        callable = handler,
-        args = ('registerUtility',
-                SMTPMailer(hostname, port, username, password), IMailer, name)
-        )

Deleted: Zope3/branches/jim-adapter/src/zope/sendmail/metadirectives.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/sendmail/metadirectives.py	2006-04-19 13:16:35 UTC (rev 67126)
+++ Zope3/branches/jim-adapter/src/zope/sendmail/metadirectives.py	2006-04-19 13:35:20 UTC (rev 67127)
@@ -1,94 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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' ZCML Namespaces Schemas
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.configuration.fields import Path
-from zope.interface import Interface
-from zope.schema import TextLine, ASCII, BytesLine, Int
-from zope.security.zcml import Permission
-
-class IDeliveryDirective(Interface):
-    """This abstract directive describes a generic mail delivery utility
-    registration."""
-    
-    name = TextLine(
-        title=u"Name",
-        description=u'Specifies the Delivery name of the mail utility. '\
-                    u'The default is "Mail".',
-        default=u"Mail",
-        required=False)
-
-    permission = Permission(
-        title=u"Permission",
-        description=u"Defines the permission needed to use this service.",
-        required=True)
-    
-    mailer = TextLine(
-        title=u"Mailer",
-        description=u"Defines the mailer to be used for sending mail.",
-        required=True)
-
-
-class IQueuedDeliveryDirective(IDeliveryDirective):
-    """This directive creates and registers a global queued mail utility. It
-    should be only called once during startup."""
-
-    queuePath = Path(
-        title=u"Queue Path",
-        description=u"Defines the path for the queue directory.",
-        required=True)
-
-
-class IDirectDeliveryDirective(IDeliveryDirective):
-    """This directive creates and registers a global direct mail utility. It
-    should be only called once during startup."""
-
-
-class IMailerDirective(Interface):
-    """A generic directive registering a mailer for the mail utility."""
-
-    name = TextLine(
-        title=u"Name",
-        description=u"Name of the Mailer.",
-        required=True)
-    
-
-class ISMTPMailerDirective(IMailerDirective):
-    """Registers a new SMTP mailer."""
-
-    hostname = BytesLine(
-        title=u"Hostname",
-        description=u"Hostname of the SMTP host.",
-        default="localhost",
-        required=False)
-
-    port = Int(
-        title=u"Port",
-        description=u"Port of the SMTP server.",
-        default=25,
-        required=False)
-
-    username = TextLine(
-        title=u"Username",
-        description=u"A username for SMTP AUTH.",
-        required=False)
-
-    password = TextLine(
-        title=u"Password",
-        description=u"A password for SMTP AUTH.",
-        required=False)

Copied: Zope3/branches/jim-adapter/src/zope/sendmail/zcml.py (from rev 67125, Zope3/branches/jim-adapter/src/zope/sendmail/metadirectives.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/sendmail/metadirectives.py	2006-04-19 12:46:56 UTC (rev 67125)
+++ Zope3/branches/jim-adapter/src/zope/sendmail/zcml.py	2006-04-19 13:35:20 UTC (rev 67127)
@@ -0,0 +1,157 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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' ZCML Namespaces Schemas
+
+$Id$
+"""
+__docformat__ = 'restructuredtext'
+
+from zope.component import queryUtility
+from zope.component.zcml import handler, proxify, PublicPermission
+from zope.configuration.fields import Path
+from zope.configuration.exceptions import ConfigurationError
+from zope.interface import Interface
+from zope.schema import TextLine, ASCII, BytesLine, Int
+from zope.security.checker import InterfaceChecker, CheckerPublic
+from zope.security.zcml import Permission
+
+from zope.sendmail.delivery import QueuedMailDelivery, DirectMailDelivery
+from zope.sendmail.delivery import QueueProcessorThread
+from zope.sendmail.interfaces import IMailer, IMailDelivery
+from zope.sendmail.mailer import SMTPMailer
+
+def _assertPermission(permission, interfaces, component):
+    if permission is not None:
+        if permission == PublicPermission:
+            permission = CheckerPublic
+        checker = InterfaceChecker(interfaces, permission)
+
+    return proxify(component, checker)
+
+class IDeliveryDirective(Interface):
+    """This abstract directive describes a generic mail delivery utility
+    registration."""
+    
+    name = TextLine(
+        title=u"Name",
+        description=u'Specifies the Delivery name of the mail utility. '\
+                    u'The default is "Mail".',
+        default=u"Mail",
+        required=False)
+
+    permission = Permission(
+        title=u"Permission",
+        description=u"Defines the permission needed to use this service.",
+        required=True)
+    
+    mailer = TextLine(
+        title=u"Mailer",
+        description=u"Defines the mailer to be used for sending mail.",
+        required=True)
+
+
+class IQueuedDeliveryDirective(IDeliveryDirective):
+    """This directive creates and registers a global queued mail utility. It
+    should be only called once during startup."""
+
+    queuePath = Path(
+        title=u"Queue Path",
+        description=u"Defines the path for the queue directory.",
+        required=True)
+
+def queuedDelivery(_context, permission, queuePath, mailer, name="Mail"):
+
+    def createQueuedDelivery():
+        delivery = QueuedMailDelivery(queuePath)
+        delivery = _assertPermission(permission, IMailDelivery, delivery)
+
+        handler('registerUtility', delivery, IMailDelivery, name)
+
+        mailerObject = queryUtility(IMailer, mailer)
+        if mailerObject is None:
+            raise ConfigurationError("Mailer %r is not defined" %mailer)
+
+        thread = QueueProcessorThread()
+        thread.setMailer(mailerObject)
+        thread.setQueuePath(queuePath)
+        thread.start()
+
+    _context.action(
+            discriminator = ('delivery', name),
+            callable = createQueuedDelivery,
+            args = () )
+
+class IDirectDeliveryDirective(IDeliveryDirective):
+    """This directive creates and registers a global direct mail utility. It
+    should be only called once during startup."""
+
+def directDelivery(_context, permission, mailer, name="Mail"):
+
+    def createDirectDelivery():
+        mailerObject = queryUtility(IMailer, mailer)
+        if mailerObject is None:
+            raise ConfigurationError("Mailer %r is not defined" %mailer)
+
+        delivery = DirectMailDelivery(mailerObject)
+        delivery = _assertPermission(permission, IMailDelivery, delivery)
+
+        handler('registerUtility', delivery, IMailDelivery, name)
+
+    _context.action(
+            discriminator = ('utility', IMailDelivery, name),
+            callable = createDirectDelivery,
+            args = () )
+
+class IMailerDirective(Interface):
+    """A generic directive registering a mailer for the mail utility."""
+
+    name = TextLine(
+        title=u"Name",
+        description=u"Name of the Mailer.",
+        required=True)
+    
+
+class ISMTPMailerDirective(IMailerDirective):
+    """Registers a new SMTP mailer."""
+
+    hostname = BytesLine(
+        title=u"Hostname",
+        description=u"Hostname of the SMTP host.",
+        default="localhost",
+        required=False)
+
+    port = Int(
+        title=u"Port",
+        description=u"Port of the SMTP server.",
+        default=25,
+        required=False)
+
+    username = TextLine(
+        title=u"Username",
+        description=u"A username for SMTP AUTH.",
+        required=False)
+
+    password = TextLine(
+        title=u"Password",
+        description=u"A password for SMTP AUTH.",
+        required=False)
+
+def smtpMailer(_context, name, hostname="localhost", port="25",
+               username=None, password=None):
+    _context.action(
+        discriminator = ('utility', IMailer, name),
+        callable = handler,
+        args = ('registerUtility',
+                SMTPMailer(hostname, port, username, password), IMailer, name)
+        )



More information about the Zope3-Checkins mailing list