1 =================================
2 Application level list life cycle
3 =================================
5 The low-level way to create and delete a mailing list is to use the
6 ``IListManager`` interface. This interface simply adds or removes the
7 appropriate database entries to record the list's creation.
9 There is a higher level interface for creating and deleting mailing lists
10 which performs additional tasks such as:
12 * validating the list's posting address (which also serves as the list's
13 fully qualified name);
14 * ensuring that the list's domain is registered;
15 * :ref:`applying a list style <list-creation-styles>` to the new list;
16 * creating and assigning list owners;
17 * notifying watchers of list creation;
18 * creating ancillary artifacts (such as the list's on-disk directory)
21 Creating a list with owners
22 ===========================
24 You can also specify a list of owner email addresses. If these addresses are
25 not yet known, they will be registered, and new users will be linked to them.
29 ... 'aperson@example.com',
30 ... 'bperson@example.com',
31 ... 'cperson@example.com',
32 ... 'dperson@example.com',
35 >>> ant = create_list('ant@example.com', owners)
36 >>> dump_list(address.email for address in ant.owners.addresses)
42 None of the owner addresses are verified.
44 >>> any(address.verified_on is not None
45 ... for address in ant.owners.addresses)
48 However, all addresses are linked to users.
50 >>> from mailman.interfaces.usermanager import IUserManager
51 >>> from zope.component import getUtility
52 >>> user_manager = getUtility(IUserManager)
53 >>> for address in owners:
54 ... user = user_manager.get_user(address)
55 ... print(int(user.user_id.int), list(user.addresses)[0])
61 If you create a mailing list with owner addresses that are already known to
62 the system, they won't be created again.
64 >>> bee = create_list('bee@example.com', owners)
65 >>> from operator import attrgetter
66 >>> for user in sorted(bee.owners.users, key=attrgetter('user_id')):
67 ... print(int(user.user_id.int), list(user.addresses)[0])
77 Removing a mailing list deletes the list, all its subscribers, and any related
81 >>> from mailman.app.lifecycle import remove_list
84 >>> from mailman.interfaces.listmanager import IListManager
85 >>> print(getUtility(IListManager).get('bee@example.com'))
88 We should now be able to completely recreate the mailing list.
90 >>> buzz = create_list('bee@example.com', owners)
91 >>> dump_list(address.email for address in bee.owners.addresses)