~barry/mailman/events-and-web

« back to all changes in this revision

Viewing changes to src/mailman/app/moderator.py

  • Committer: Barry Warsaw
  • Date: 2011-08-18 00:39:11 UTC
  • mfrom: (7036.1.4 bug-827036)
  • Revision ID: barry@list.org-20110818003911-9gef1p84g2pg4p10
 * Four new events are created, and notifications are sent during mailing list
   lifecycle changes:
   - ListCreatingEvent - sent before the mailing list is created
   - ListCreatedEvent  - sent after the mailing list is created
   - ListDeletingEvent - sent before the mailing list is deleted
   - ListDeletedEvent  - sent after the mailing list is deleted
 * Using the above events, when a mailing list is deleted, all its members are
   deleted, as well as all held message requests (but not the held messages
   themselves).  (LP: 827036)

Also: relax the find_member() argument constraints so that even the subscriber
email address is optional.  This is mirrored in the REST API's
.../members/find resource.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
__metaclass__ = type
23
23
__all__ = [
 
24
    'handle_ListDeletingEvent',
24
25
    'handle_message',
25
26
    'handle_subscription',
26
27
    'handle_unsubscription',
43
44
from mailman.email.message import UserNotification
44
45
from mailman.interfaces.action import Action
45
46
from mailman.interfaces.languages import ILanguageManager
 
47
from mailman.interfaces.listmanager import ListDeletingEvent
46
48
from mailman.interfaces.member import (
47
49
    AlreadySubscribedError, DeliveryMode, NotAMemberError)
48
50
from mailman.interfaces.messages import IMessageStore
355
357
        subject = _('Request to mailing list "$realname" rejected')
356
358
    msg = UserNotification(recip, mlist.bounces_address, subject, text, lang)
357
359
    msg.send(mlist)
 
360
 
 
361
 
 
362
 
 
363
def handle_ListDeletingEvent(event):
 
364
    if not isinstance(event, ListDeletingEvent):
 
365
        return
 
366
    # Get the held requests database for the mailing list.  Since the mailing
 
367
    # list is about to get deleted, we can delete all associated requests.
 
368
    requestsdb = getUtility(IRequests).get_list_requests(event.mailing_list)
 
369
    for request in requestsdb.held_requests:
 
370
        requestsdb.delete_request(request.id)