16
16
>>> from operator import attrgetter
17
>>> def show_domains():
17
>>> def show_domains(*, with_owners=False):
18
18
... if len(manager) == 0:
19
19
... print('no domains')
21
21
... for domain in sorted(manager, key=attrgetter('mail_host')):
23
... owners = sorted(owner.addresses[0].email
24
... for owner in domain.owners)
25
... for owner in owners:
26
... print('- owner:', owner)
28
32
is the only required piece. The other parts are inferred from that.
30
34
>>> manager.add('example.org')
31
<Domain example.org, base_url: http://example.org,
32
contact_address: postmaster@example.org>
35
<Domain example.org, base_url: http://example.org>
34
<Domain example.org, base_url: http://example.org,
35
contact_address: postmaster@example.org>
37
<Domain example.org, base_url: http://example.org>
37
39
We can remove domains too.
39
41
>>> manager.remove('example.org')
40
<Domain example.org, base_url: http://example.org,
41
contact_address: postmaster@example.org>
42
<Domain example.org, base_url: http://example.org>
46
47
web interface for the domain.
48
49
>>> manager.add('example.com', base_url='https://mail.example.com')
49
<Domain example.com, base_url: https://mail.example.com,
50
contact_address: postmaster@example.com>
50
<Domain example.com, base_url: https://mail.example.com>
52
<Domain example.com, base_url: https://mail.example.com,
53
contact_address: postmaster@example.com>
52
<Domain example.com, base_url: https://mail.example.com>
55
Domains can have explicit descriptions and contact addresses.
54
Domains can have explicit descriptions, and can be created with one or more
60
60
... base_url='http://lists.example.net',
61
... contact_address='postmaster@example.com',
62
... description='The example domain')
63
<Domain example.net, The example domain,
64
base_url: http://lists.example.net,
65
contact_address: postmaster@example.com>
68
<Domain example.com, base_url: https://mail.example.com,
69
contact_address: postmaster@example.com>
70
<Domain example.net, The example domain,
71
base_url: http://lists.example.net,
72
contact_address: postmaster@example.com>
61
... description='The example domain',
62
... owners=['anne@example.com'])
63
<Domain example.net, The example domain,
64
base_url: http://lists.example.net>
66
>>> show_domains(with_owners=True)
67
<Domain example.com, base_url: https://mail.example.com>
68
<Domain example.net, The example domain,
69
base_url: http://lists.example.net>
70
- owner: anne@example.com
72
Domains can have multiple owners, ideally one of the owners should have a
73
verified preferred address. However this is not checked right now and the
74
configuration's default contact address may be used as a fallback.
76
>>> net_domain = manager['example.net']
77
>>> net_domain.add_owner('bart@example.org')
78
>>> show_domains(with_owners=True)
79
<Domain example.com, base_url: https://mail.example.com>
80
<Domain example.net, The example domain, base_url: http://lists.example.net>
81
- owner: anne@example.com
82
- owner: bart@example.org
74
84
Domains can list all associated mailing lists with the mailing_lists property.
106
116
>>> print(manager['example.net'])
107
117
<Domain example.net, The example domain,
108
base_url: http://lists.example.net,
109
contact_address: postmaster@example.com>
118
base_url: http://lists.example.net>
111
120
As with dictionaries, you can also get the domain. If the domain does not
112
121
exist, ``None`` or a default is returned.