[Zope3-checkins] CVS: Zope3/src/zope/app/mail - metadirectives.py:1.1 configure.zcml:1.5 meta.zcml:1.3 metaconfigure.py:1.4
Stephan Richter
srichter@cosmos.phy.tufts.edu
Sat, 2 Aug 2003 08:30:59 -0400
Update of /cvs-repository/Zope3/src/zope/app/mail
In directory cvs.zope.org:/tmp/cvs-serv23612
Modified Files:
configure.zcml meta.zcml metaconfigure.py
Added Files:
metadirectives.py
Log Message:
Converted 'mail' ZCML namespace. tests and ftests pass.
=== Added File Zope3/src/zope/app/mail/metadirectives.py ===
##############################################################################
#
# 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.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' ZCML Namespaces Schemas
$Id: metadirectives.py,v 1.1 2003/08/02 12:30:24 srichter Exp $
"""
from zope.configuration.fields import GlobalObject, Path
from zope.interface import Interface
from zope.schema import TextLine, Bytes, BytesLine, Int
class IServiceDirective(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. '\
u'The default is "Mail".',
default=u"Mail",
required=False)
permission = TextLine(
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 IQueuedServiceDirective(IServiceDirective):
"""This directive creates and registers a global queued mail service. 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 IDirectServiceDirective(IServiceDirective):
"""This directive creates and registers a global direct mail service. It
should be only called once during startup."""
class IMailerDirective(Interface):
"""A generic directive registering a mailer for the mail service."""
id = TextLine(
title=u"Id",
description=u"Id of the Mailer.",
required=True)
class ISendmailMailerDirective(IMailerDirective):
"""Registers a new Sendmail mailer."""
command = Bytes(
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."""
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=23,
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)
=== Zope3/src/zope/app/mail/configure.zcml 1.4 => 1.5 ===
--- Zope3/src/zope/app/mail/configure.zcml:1.4 Mon Jun 30 12:58:41 2003
+++ Zope3/src/zope/app/mail/configure.zcml Sat Aug 2 08:30:24 2003
@@ -1,19 +1,16 @@
-<zopeConfigure
+<configure
xmlns="http://namespaces.zope.org/zope"
- xmlns:mail="http://namespaces.zope.org/mail"
- >
+ xmlns:mail="http://namespaces.zope.org/mail">
<serviceType
id="Mail"
- interface="zope.app.interfaces.mail.IMailService"
- />
+ interface="zope.app.interfaces.mail.IMailService"/>
<permission
id="zope.SendMail"
- title="Send out mail with arbitrary from and to addresses"
- />
+ title="Send out mail with arbitrary from and to addresses"/>
- <mail:sendmailMailer id="sendmail" />
+ <mail:sendmailMailer id="sendmail"/>
<mail:smtpMailer id="smtp" hostname="localhost" port="25" />
@@ -26,4 +23,4 @@
mailer="smtp" />
-->
-</zopeConfigure>
+</configure>
=== Zope3/src/zope/app/mail/meta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/mail/meta.zcml:1.2 Mon Jun 23 11:45:39 2003
+++ Zope3/src/zope/app/mail/meta.zcml Sat Aug 2 08:30:24 2003
@@ -1,128 +1,29 @@
-<zopeConfigure xmlns="http://namespaces.zope.org/zope">
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta">
+
+ <meta:directive
+ namespace="http://namespaces.zope.org/mail"
+ name="queuedService"
+ schema=".metadirectives.IQueuedServiceDirective"
+ handler=".metaconfigure.queuedService" />
+
+ <meta:directive
+ namespace="http://namespaces.zope.org/mail"
+ name="directService"
+ schema=".metadirectives.IDirectServiceDirective"
+ handler=".metaconfigure.directService" />
+
+ <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" />
- <directives namespace="http://namespaces.zope.org/mail">
-
- <directive name="queuedService" handler=".metaconfigure.queuedService">
-
- <description>
- This directive creates and registers a global queued mail service. It
- should be only called once during startup.
- </description>
-
- <attribute name="name" required="no">
- <description>
- Specifies the Service name of the mail service. The default is
- "Mail".
- </description>
- </attribute>
-
- <attribute name="permission" required="yes">
- <description>
- Defines the permission that is required to use this object.
- </description>
- </attribute>
-
- <attribute name="queuePath" required="yes">
- <description>
- Defines the path for the queue directory.
- </description>
- </attribute>
-
- <attribute name="mailer" required="yes">
- <description>
- The id of the mailer used by this service.
- </description>
- </attribute>
-
- </directive>
-
- <directive name="directService" handler=".metaconfigure.directService">
-
- <description>
- This directive creates and registers a global direct mail service. It
- should be only called once during startup.
- </description>
-
- <attribute name="name" required="no">
- <description>
- Specifies the Service name of the mail service. The default is
- "Mail".
- </description>
- </attribute>
-
- <attribute name="permission" required="yes">
- <description>
- Defines the permission that is required to use this object.
- </description>
- </attribute>
-
- <attribute name="mailer" required="yes">
- <description>
- Defines the mailer to be used for sending mail.
- </description>
- </attribute>
-
- </directive>
-
- <directive name="sendmailMailer" handler=".metaconfigure.sendmailMailer">
-
- <description>
- Registers a new Sendmail mailer.
- </description>
-
- <attribute name="id" required="yes">
- <description>
- Id of the mailer.
- </description>
- </attribute>
-
- <attribute name="command" required="no">
- <description>
- A template command for sending out mail, containing %(from)s
- and %(to)s for respective addresses.
- </description>
- </attribute>
-
- </directive>
-
- <directive name="smtpMailer" handler=".metaconfigure.smtpMailer">
-
- <description>
- Registers a new SMTP mailer.
- </description>
-
- <attribute name="id" required="yes">
- <description>
- Name of the mailer.
- </description>
- </attribute>
-
- <attribute name="hostname" required="no">
- <description>
- Hostname of the SMTP host.
- </description>
- </attribute>
-
- <attribute name="port" required="no">
- <description>
- Port of the SMTP server.
- </description>
- </attribute>
-
- <attribute name="username" required="no">
- <description>
- A username for SMTP AUTH.
- </description>
- </attribute>
-
- <attribute name="password" required="no">
- <description>
- A password for SMTP AUTH.
- </description>
- </attribute>
-
- </directive>
-
- </directives>
-
-</zopeConfigure>
+</configure>
=== Zope3/src/zope/app/mail/metaconfigure.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/mail/metaconfigure.py:1.3 Mon Jun 23 11:45:39 2003
+++ Zope3/src/zope/app/mail/metaconfigure.py Sat Aug 2 08:30:24 2003
@@ -15,7 +15,6 @@
$Id$
"""
-
from zope.component import getService
from zope.configuration.action import Action
from zope.configuration.exceptions import ConfigurationError
@@ -26,9 +25,6 @@
def queuedService(_context, permission, queuePath, mailer, name="Mail"):
- # XXX what if queuePath is relative? I'd like to make it absolute here,
- # but should it be relative to $CWD or $INSTANCE_HOME (if there is one
- # in Zope 3)?
def createQueuedService():
component = QueuedMailService(queuePath)
@@ -40,13 +36,10 @@
thread.setDaemon(True)
thread.start()
- return [
- Action(
+ _context.action(
discriminator = ('service', name),
callable = createQueuedService,
- args = (),
- )
- ]
+ args = () )
def directService(_context, permission, mailer, name="Mail"):
@@ -57,30 +50,26 @@
component = DirectMailService(mailer_component)
provideService(name, component, permission)
- return [
- Action(
+ _context.action(
discriminator = ('service', name),
callable = makeService,
- args = (),
- )
- ]
+ args = () )
def sendmailMailer(_context, id,
command="/usr/lib/sendmail -oem -oi -f %(from)s %(to)s"):
- return [Action(discriminator=('mailer', id),
- callable=provideMailer,
- args=(id, SendmailMailer(command)),)
- ]
+ _context.action(
+ discriminator=('mailer', id),
+ callable=provideMailer,
+ args=(id, SendmailMailer(command)) )
def smtpMailer(_context, id, hostname="localhost", port="25",
username=None, password=None):
- return [Action(discriminator=('mailer', id),
- callable=provideMailer,
- args=(id, SMTPMailer(hostname, port,
- username, password)),)
- ]
+ _context.action(
+ discriminator=('mailer', id),
+ callable=provideMailer,
+ args=(id, SMTPMailer(hostname, port, username, password)) )
# Example of mailer configuration:
#