103
107
self.stop_processing = stop_processing
110
class UnknownRecipientError(KeyError):
111
"""Error raised when an email or person isn't part of the recipient set.
115
class INotificationRecipientSet(Interface):
116
"""Represents a set of notification recipients and rationales.
118
All Launchpad emails should include a footer explaining why the user
119
is receiving the email. An INotificationRecipientSet encapsulates a
120
list of recipients along the rationale for being on the recipients list.
122
The pattern for using this are as follows: email addresses in an
123
INotificationRecipientSet are being notified because of a specific
124
event (for instance, because a bug changed). The rationales describe
125
why that email addresses is included in the recipient list,
126
detailing subscription types, membership in teams and/or other
129
The set maintains the list of `IPerson` that will be contacted as well
130
as the email address to use to contact them.
134
"""Return all email addresses registered, sorted alphabetically."""
137
"""Return the set of person who will be notified.
139
:return: An iterator of `IPerson`, sorted by display name.
142
def getRecipientPersons():
143
"""Return the set of individual Persons who will be notified.
145
:return: An iterator of (`email_address`, `IPerson`), unsorted.
149
"""Return an iterator of the recipients."""
151
def __contains__(person_or_email):
152
"""Is person_or_email in the notification recipients list?
154
Return true if person or email is in the notification recipients list.
158
"""Return False when the set is empty, True when it's not."""
160
def getReason(person_or_email):
161
"""Return a reason tuple containing (text, header) for an address.
163
The text is meant to appear in the notification footer. The header
164
should be a short code that will appear in an
165
X-Launchpad-Message-Rationale header for automatic filtering.
167
:param person_or_email: An `IPerson` or email address that is in the
170
:raises UnknownRecipientError: if the person or email isn't in the
174
def add(person, reason, header):
175
"""Add a person or a sequence of persons to the recipients list.
177
When the added person is a team without an email address, all its
178
members emails will be added. If the person is already in the
179
recipients list, the reson for contacting him is not changed.
181
:param person: The `IPerson` or a sequence of `IPerson`
182
that will be notified.
183
:param reason: The rationale message that should appear in the
185
:param header: The code that will appear in the
186
X-Launchpad-Message-Rationale header.
190
"""Remove a person or a list of persons from the recipients list.
192
:param person: The `IPerson` or a sequence of `IPerson`
193
that will removed from the recipients list.
196
def update(recipient_set):
197
"""Updates this instance's reasons with reasons from another set.
199
The rationale for recipient already in this set will not be updated.
201
:param recipient_set: An `INotificationRecipientSet`.
106
205
class BugTargetNotFound(Exception):
107
206
"""A bug target couldn't be found."""