~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/mail/meta.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-13 01:11:42 UTC
  • mfrom: (13668.1.31 private-bug-0)
  • Revision ID: launchpad@pqm.canonical.com-20110813011142-b8xvpxhdja422ln2
[rs=sinzui][no-qa] Moved canonical.launchpad.mail to lp.services.mail,
 bugs.mail, code.mail.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
__metaclass__ = type
15
15
from zope.sendmail.interfaces import IMailer
16
16
from zope.sendmail.zcml import IMailerDirective
17
17
 
18
 
from canonical.launchpad.interfaces.mailbox import IMailBox
19
18
from lp.services.mail.mailbox import (
20
19
    DirectoryMailBox,
 
20
    IMailBox,
21
21
    POP3MailBox,
22
22
    TestMailBox,
23
23
    )
31
31
class ITestMailBoxDirective(Interface):
32
32
    """Configure a mail box which operates on test_emails."""
33
33
 
 
34
 
34
35
def testMailBoxHandler(_context):
35
36
    utility(_context, IMailBox, component=TestMailBox())
36
37
 
61
62
            required=False,
62
63
            default=False)
63
64
 
 
65
 
64
66
def pop3MailBoxHandler(_context, host, user, password, ssl=False):
65
67
    utility(
66
 
        _context, IMailBox, component=POP3MailBox( host, user, password, ssl))
 
68
        _context, IMailBox, component=POP3MailBox(host, user, password, ssl))
67
69
 
68
70
 
69
71
class IDirectoryMailBoxDirective(Interface):
88
90
            )
89
91
    to_addr = ASCII(
90
92
            title=u"To Address",
91
 
            description=
92
 
                (u"All outgoing emails will be redirected to this email "
93
 
                 u"address"),
 
93
            description=(
 
94
                u"All outgoing emails will be redirected to this email "
 
95
                u"address"),
94
96
            required=True,
95
97
            )
96
98
    mailer = ASCII(
115
117
def stubMailerHandler(_context, name, from_addr, to_addr,
116
118
                      mailer='smtp', rewrite=False):
117
119
    _context.action(
118
 
        discriminator = ('utility', IMailer, name),
119
 
        callable = handler,
120
 
        args = ('registerUtility',
 
120
        discriminator=('utility', IMailer, name),
 
121
        callable=handler,
 
122
        args=('registerUtility',
121
123
                StubMailer(from_addr, [to_addr], mailer, rewrite),
122
124
                IMailer, name)
123
125
        )
129
131
 
130
132
def testMailerHandler(_context, name):
131
133
    _context.action(
132
 
        discriminator = ('utility', IMailer, name),
133
 
        callable = handler,
134
 
        args = ('registerUtility', TestMailer(), IMailer, name)
 
134
        discriminator=('utility', IMailer, name),
 
135
        callable=handler,
 
136
        args=('registerUtility', TestMailer(), IMailer, name)
135
137
        )
136
138
 
137
139
 
161
163
 
162
164
def mboxMailerHandler(_context, name, filename, overwrite, mailer=None):
163
165
    _context.action(
164
 
        discriminator = ('utility', IMailer, name),
165
 
        callable = handler,
166
 
        args = ('registerUtility',
 
166
        discriminator=('utility', IMailer, name),
 
167
        callable=handler,
 
168
        args=('registerUtility',
167
169
                MboxMailer(filename, overwrite, mailer),
168
170
                IMailer, name)
169
171
        )