Merge ~cjwatson/launchpad:zcml-namespaces-mail into launchpad:master

Proposed by Colin Watson
Status: Needs review
Proposed branch: ~cjwatson/launchpad:zcml-namespaces-mail
Merge into: launchpad:master
Diff against target: 242 lines (+56/-23)
6 files modified
configs/development/directory-testing-mailbox.zcml.example (+3/-3)
doc/reference/email.rst (+11/-10)
lib/lp/services/mail/doc/mailbox.rst (+2/-2)
lib/lp/services/mail/meta.zcml (+35/-5)
zcml/package-includes/mail-configure-normal.zcml (+2/-1)
zcml/package-includes/mail-configure-testing.zcml (+3/-2)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+437576@code.launchpad.net

Commit message

Move ZCML mail-related directives to lp namespace

Description of the change

As with commit 57196c1d6a220f00039e027768cc05368135f556, it makes sense to move our various local `*MailBox` and `*Mailer` directives to our own namespace rather than poking them into the Zope mail namespace.

We retain some backward-compatibility registrations with the old namespace for the time being, as these directives appear in some per-environment configuration files.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :
review: Approve

Unmerged commits

9c0ae68... by Colin Watson

Move ZCML mail-related directives to lp namespace

As with commit 57196c1d6a220f00039e027768cc05368135f556, it makes sense
to move our various local `*MailBox` and `*Mailer` directives to our own
namespace rather than poking them into the Zope mail namespace.

We retain some backward-compatibility registrations with the old
namespace for the time being, as these directives appear in some
per-environment configuration files.

Succeeded
[SUCCEEDED] docs:0 (build)
[SUCCEEDED] lint:0 (build)
[SUCCEEDED] mypy:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/configs/development/directory-testing-mailbox.zcml.example b/configs/development/directory-testing-mailbox.zcml.example
index 64301cc..2af8d69 100644
--- a/configs/development/directory-testing-mailbox.zcml.example
+++ b/configs/development/directory-testing-mailbox.zcml.example
@@ -1,8 +1,8 @@
1<configure1<configure
2 xmlns="http://namespaces.zope.org/zope"2 xmlns="http://namespaces.zope.org/zope"
3 xmlns:mail="http://namespaces.zope.org/mail">3 xmlns:lp="http://namespaces.canonical.com/lp">
44
5 <mail:directoryMailBox5 <lp:directoryMailBox
6 directory="/var/tmp/launchpad_script_mailbox" />6 directory="/var/tmp/launchpad_script_mailbox" />
77
8</configure>
9\ No newline at end of file8\ No newline at end of file
9</configure>
diff --git a/doc/reference/email.rst b/doc/reference/email.rst
index 12d19f7..21fa9cf 100644
--- a/doc/reference/email.rst
+++ b/doc/reference/email.rst
@@ -22,6 +22,7 @@ similar to the following::
2222
23 <configure23 <configure
24 xmlns="http://namespaces.zope.org/zope"24 xmlns="http://namespaces.zope.org/zope"
25 xmlns:lp="http://namespaces.canonical.com/lp"
25 xmlns:mail="http://namespaces.zope.org/mail"26 xmlns:mail="http://namespaces.zope.org/mail"
26 i18n_domain="zope">27 i18n_domain="zope">
2728
@@ -35,7 +36,7 @@ similar to the following::
35 password="pass"36 password="pass"
36 />37 />
3738
38 <mail:stubMailer39 <lp:stubMailer
39 name="stub"40 name="stub"
40 from_addr="stuart@stuartbishop.net"41 from_addr="stuart@stuartbishop.net"
41 to_addr="stuart@stuartbishop.net"42 to_addr="stuart@stuartbishop.net"
@@ -43,9 +44,9 @@ similar to the following::
43 rewrite="false"44 rewrite="false"
44 />45 />
4546
46 <mail:testMailer name="test-mailer" />47 <lp:testMailer name="test-mailer" />
4748
48 <mail:mboxMailer49 <lp:mboxMailer
49 name="mbox"50 name="mbox"
50 filename="/tmp/launchpad.mbox"51 filename="/tmp/launchpad.mbox"
51 overwrite="true"52 overwrite="true"
@@ -86,25 +87,25 @@ most people won't actually need the `mail:smtpMailer` tag because the defaults
86will usually just work. However, several additional mailers are available for87will usually just work. However, several additional mailers are available for
87you to use, depending on what you're trying to do.88you to use, depending on what you're trying to do.
8889
89The `mail:stubMailer` can be used to forward all emails to your normal inbox90The `lp:stubMailer` can be used to forward all emails to your normal inbox
90via some other mailer. Think of it as a proxy mailer that can be used to91via some other mailer. Think of it as a proxy mailer that can be used to
91specify explicit MAIL FROM and RCTP TO envelope addresses. The `rewrite`92specify explicit MAIL FROM and RCTP TO envelope addresses. The `rewrite`
92attribute of the `mail:stubMailer` specifies whether the RFC 2822 headers93attribute of the `lp:stubMailer` specifies whether the RFC 2822 headers
93should also be rewritten. You and your spam filters might prefer this set to94should also be rewritten. You and your spam filters might prefer this set to
94`true`.95`true`.
9596
96The `mail:mboxMailer` stores messages in a Unix mbox file and then forwards97The `lp:mboxMailer` stores messages in a Unix mbox file and then forwards
97the message on to another mailer. You can use this if you want a record on98the message on to another mailer. You can use this if you want a record on
98disk of all the messages sent, or if you'd rather not clutter up your inbox99disk of all the messages sent, or if you'd rather not clutter up your inbox
99with all your Launchpad test email. The `overwrite` attribute says whether to100with all your Launchpad test email. The `overwrite` attribute says whether to
100truncate the mbox file when Launchpad starts up (i.e. opens the file once in101truncate the mbox file when Launchpad starts up (i.e. opens the file once in
101'w' mode before appending all new messages to the file).102'w' mode before appending all new messages to the file).
102103
103The `mail:testMailer` is necessary for the Launchpad tests to work. You must104The `lp:testMailer` is necessary for the Launchpad tests to work. You must
104use a `mail:directDelivery` mailer for the tests, otherwise you'll get lots of105use a `mail:directDelivery` mailer for the tests, otherwise you'll get lots of
105failures. Basically, the testMailer stores the messages in a list in memory.106failures. Basically, the testMailer stores the messages in a list in memory.
106107
107For both `mail:mboxMailer` and `mail:stubMailer` the `mailer` attribute108For both `mail:mboxMailer` and `lp:stubMailer` the `mailer` attribute
108specifies the next mailer in the chain that the message will get sent to.109specifies the next mailer in the chain that the message will get sent to.
109Thus if `mailer` is set to `smtp`, you'll get the messages in your inbox, but110Thus if `mailer` is set to `smtp`, you'll get the messages in your inbox, but
110if it's `test-mailer`, the unit tests will work.111if it's `test-mailer`, the unit tests will work.
@@ -112,14 +113,14 @@ if it's `test-mailer`, the unit tests will work.
112Finally, these are all hooked up at the top with either a113Finally, these are all hooked up at the top with either a
113`mail:queuedDelivery` section or a `mail:directDelivery` tag. You must114`mail:queuedDelivery` section or a `mail:directDelivery` tag. You must
114use a `mail:directDelivery` tag if you want the unit tests to work because115use a `mail:directDelivery` tag if you want the unit tests to work because
115otherwise, the in-memory list of the `mail:testMailer` won't be updated by the116otherwise, the in-memory list of the `lp:testMailer` won't be updated by the
116time the unit test checks it.117time the unit test checks it.
117118
118If you just want the unit tests to work normally, don't include a119If you just want the unit tests to work normally, don't include a
119`mail:queuedDelivery` or a `mail:directDelivery` section at all. Launchpad120`mail:queuedDelivery` or a `mail:directDelivery` section at all. Launchpad
120will DTRT internally. However, if you want copies in an mbox file or in your121will DTRT internally. However, if you want copies in an mbox file or in your
121inbox, set the `mailer` attribute to the appropriate mailer, chaining that to122inbox, set the `mailer` attribute to the appropriate mailer, chaining that to
122a `mail:testMailer` for the unit tests or a `mail:smtpMailer` for123an `lp:testMailer` for the unit tests or a `mail:smtpMailer` for
123development.124development.
124125
125126
diff --git a/lib/lp/services/mail/doc/mailbox.rst b/lib/lp/services/mail/doc/mailbox.rst
index 454b10f..e9f9ec0 100644
--- a/lib/lp/services/mail/doc/mailbox.rst
+++ b/lib/lp/services/mail/doc/mailbox.rst
@@ -7,11 +7,11 @@ box.
7There's also an IMailBox which interfaces with a POP3 server. It can be7There's also an IMailBox which interfaces with a POP3 server. It can be
8configured in ZCML with:8configured in ZCML with:
99
10 <mail:pop3MailBox host="somehost" user="someuser" password="secret" />10 <lp:pop3MailBox host="somehost" user="someuser" password="secret" />
1111
12It also supports POP3 over ssl:12It also supports POP3 over ssl:
1313
14 <mail:pop3MailBox14 <lp:pop3MailBox
15 host="somehost" user="someuser" password="secret" ssl="true" />15 host="somehost" user="someuser" password="secret" ssl="true" />
1616
17The third is the DirectoryMailBox and can be configured to operate for17The third is the DirectoryMailBox and can be configured to operate for
diff --git a/lib/lp/services/mail/meta.zcml b/lib/lp/services/mail/meta.zcml
index 64d18f8..2593232 100644
--- a/lib/lp/services/mail/meta.zcml
+++ b/lib/lp/services/mail/meta.zcml
@@ -7,41 +7,71 @@
7 xmlns:meta="http://namespaces.zope.org/meta">7 xmlns:meta="http://namespaces.zope.org/meta">
88
9 <meta:directive9 <meta:directive
10 namespace="http://namespaces.zope.org/mail"10 namespace="http://namespaces.canonical.com/lp"
11 name="testMailBox"11 name="testMailBox"
12 schema=".meta.ITestMailBoxDirective"12 schema=".meta.ITestMailBoxDirective"
13 handler=".meta.testMailBoxHandler"13 handler=".meta.testMailBoxHandler"
14 />14 />
1515
16 <meta:directive16 <meta:directive
17 namespace="http://namespaces.zope.org/mail"17 namespace="http://namespaces.canonical.com/lp"
18 name="pop3MailBox"18 name="pop3MailBox"
19 schema=".meta.IPOP3MailBoxDirective"19 schema=".meta.IPOP3MailBoxDirective"
20 handler=".meta.pop3MailBoxHandler"20 handler=".meta.pop3MailBoxHandler"
21 />21 />
2222
23 <meta:directive23 <meta:directive
24 namespace="http://namespaces.zope.org/mail"24 namespace="http://namespaces.canonical.com/lp"
25 name="directoryMailBox"25 name="directoryMailBox"
26 schema=".meta.IDirectoryMailBoxDirective"26 schema=".meta.IDirectoryMailBoxDirective"
27 handler=".meta.directorymailBoxHandler"27 handler=".meta.directorymailBoxHandler"
28 />28 />
2929
30 <meta:directive30 <meta:directive
31 namespace="http://namespaces.zope.org/mail"31 namespace="http://namespaces.canonical.com/lp"
32 name="stubMailer"32 name="stubMailer"
33 schema=".meta.IStubMailerDirective"33 schema=".meta.IStubMailerDirective"
34 handler=".meta.stubMailerHandler"34 handler=".meta.stubMailerHandler"
35 />35 />
3636
37 <meta:directive37 <meta:directive
38 namespace="http://namespaces.zope.org/mail"38 namespace="http://namespaces.canonical.com/lp"
39 name="testMailer"39 name="testMailer"
40 schema=".meta.ITestMailerDirective"40 schema=".meta.ITestMailerDirective"
41 handler=".meta.testMailerHandler"41 handler=".meta.testMailerHandler"
42 />42 />
4343
44 <meta:directive44 <meta:directive
45 namespace="http://namespaces.canonical.com/lp"
46 name="mboxMailer"
47 schema=".meta.IMboxMailerDirective"
48 handler=".meta.mboxMailerHandler"
49 />
50
51 <!-- Backward-compatibility with existing configurations. -->
52
53 <meta:directive
54 namespace="http://namespaces.zope.org/mail"
55 name="pop3MailBox"
56 schema=".meta.IPOP3MailBoxDirective"
57 handler=".meta.pop3MailBoxHandler"
58 />
59
60 <meta:directive
61 namespace="http://namespaces.zope.org/mail"
62 name="directoryMailBox"
63 schema=".meta.IDirectoryMailBoxDirective"
64 handler=".meta.directorymailBoxHandler"
65 />
66
67 <meta:directive
68 namespace="http://namespaces.zope.org/mail"
69 name="stubMailer"
70 schema=".meta.IStubMailerDirective"
71 handler=".meta.stubMailerHandler"
72 />
73
74 <meta:directive
45 namespace="http://namespaces.zope.org/mail"75 namespace="http://namespaces.zope.org/mail"
46 name="mboxMailer"76 name="mboxMailer"
47 schema=".meta.IMboxMailerDirective"77 schema=".meta.IMboxMailerDirective"
diff --git a/zcml/package-includes/mail-configure-normal.zcml b/zcml/package-includes/mail-configure-normal.zcml
index 8211f06..c5313a0 100644
--- a/zcml/package-includes/mail-configure-normal.zcml
+++ b/zcml/package-includes/mail-configure-normal.zcml
@@ -4,12 +4,13 @@
44
5<configure5<configure
6 xmlns="http://namespaces.zope.org/zope"6 xmlns="http://namespaces.zope.org/zope"
7 xmlns:lp="http://namespaces.canonical.com/lp"
7 xmlns:mail="http://namespaces.zope.org/mail"8 xmlns:mail="http://namespaces.zope.org/mail"
8 i18n_domain="zope">9 i18n_domain="zope">
910
10 <include package="zope.sendmail"/>11 <include package="zope.sendmail"/>
1112
12 <mail:stubMailer13 <lp:stubMailer
13 name="stub" from_addr="root@localhost" to_addr="root@localhost"14 name="stub" from_addr="root@localhost" to_addr="root@localhost"
14 />15 />
1516
diff --git a/zcml/package-includes/mail-configure-testing.zcml b/zcml/package-includes/mail-configure-testing.zcml
index ff46164..d075d86 100644
--- a/zcml/package-includes/mail-configure-testing.zcml
+++ b/zcml/package-includes/mail-configure-testing.zcml
@@ -4,6 +4,7 @@
44
5<configure5<configure
6 xmlns="http://namespaces.zope.org/zope"6 xmlns="http://namespaces.zope.org/zope"
7 xmlns:lp="http://namespaces.canonical.com/lp"
7 xmlns:mail="http://namespaces.zope.org/mail"8 xmlns:mail="http://namespaces.zope.org/mail"
8 i18n_domain="zope">9 i18n_domain="zope">
910
@@ -12,11 +13,11 @@
12 <!-- Configure email for testing. Use direct delivery instead of13 <!-- Configure email for testing. Use direct delivery instead of
13 queued, as otherwise tests would be more painful and the background14 queued, as otherwise tests would be more painful and the background
14 thread created by queuedDelivery causes trouble too -->15 thread created by queuedDelivery causes trouble too -->
15 <mail:testMailer name="test" />16 <lp:testMailer name="test" />
16 <mail:directDelivery name="Mail" permission="zope.SendMail" mailer="test" />17 <mail:directDelivery name="Mail" permission="zope.SendMail" mailer="test" />
1718
18 <!-- Configure a mail box which can be used when testing. Every email that19 <!-- Configure a mail box which can be used when testing. Every email that
19 you send using testMailer will appear in this mail box. -->20 you send using testMailer will appear in this mail box. -->
20 <mail:testMailBox />21 <lp:testMailBox />
2122
22</configure>23</configure>

Subscribers

People subscribed via source and target branches

to status/vote changes: