summaryrefslogtreecommitdiff
path: root/src/mailman/app/docs/lifecycle.rst
blob: f059806af2d490f0aa4288f6748d0bbaa9e92914 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
=================================
Application level list life cycle
=================================

The low-level way to create and delete a mailing list is to use the
``IListManager`` interface.  This interface simply adds or removes the
appropriate database entries to record the list's creation.

There is a higher level interface for creating and deleting mailing lists
which performs additional tasks such as:

 * validating the list's posting address (which also serves as the list's
   fully qualified name);
 * ensuring that the list's domain is registered;
 * :ref:`applying a list style <list-creation-styles>` to the new list;
 * creating and assigning list owners;
 * notifying watchers of list creation;
 * creating ancillary artifacts (such as the list's on-disk directory)


Creating a list with owners
===========================

You can also specify a list of owner email addresses.  If these addresses are
not yet known, they will be registered, and new users will be linked to them.
::

    >>> owners = [
    ...     'aperson@example.com',
    ...     'bperson@example.com',
    ...     'cperson@example.com',
    ...     'dperson@example.com',
    ...     ]

    >>> ant = create_list('ant@example.com', owners)
    >>> dump_list(address.email for address in ant.owners.addresses)
    aperson@example.com
    bperson@example.com
    cperson@example.com
    dperson@example.com

None of the owner addresses are verified.

    >>> any(address.verified_on is not None
    ...     for address in ant.owners.addresses)
    False

However, all addresses are linked to users.

    >>> from mailman.interfaces.usermanager import IUserManager
    >>> from zope.component import getUtility
    >>> user_manager = getUtility(IUserManager)
    >>> for address in owners:
    ...     user = user_manager.get_user(address)
    ...     print(int(user.user_id.int), list(user.addresses)[0])
    1 aperson@example.com
    2 bperson@example.com
    3 cperson@example.com
    4 dperson@example.com

If you create a mailing list with owner addresses that are already known to
the system, they won't be created again.

    >>> bee = create_list('bee@example.com', owners)
    >>> from operator import attrgetter
    >>> for user in sorted(bee.owners.users, key=attrgetter('user_id')):
    ...     print(int(user.user_id.int), list(user.addresses)[0])
    1 aperson@example.com
    2 bperson@example.com
    3 cperson@example.com
    4 dperson@example.com


Deleting a list
===============

Removing a mailing list deletes the list, all its subscribers, and any related
artifacts.
::

    >>> from mailman.app.lifecycle import remove_list
    >>> remove_list(bee)

    >>> from mailman.interfaces.listmanager import IListManager
    >>> print(getUtility(IListManager).get('bee@example.com'))
    None

We should now be able to completely recreate the mailing list.

    >>> buzz = create_list('bee@example.com', owners)
    >>> dump_list(address.email for address in bee.owners.addresses)
    aperson@example.com
    bperson@example.com
    cperson@example.com
    dperson@example.com