~abompard/mailman/subpolicy

« back to all changes in this revision

Viewing changes to src/mailman/model/docs/domains.rst

  • Committer: Barry Warsaw
  • Date: 2015-04-07 02:06:28 UTC
  • mfrom: (7313.2.6 lp1423756)
  • mto: This revision was merged to the branch mainline in revision 7323.
  • Revision ID: barry@list.org-20150407020628-fkwphij7to9lc8gy
 * Domains now have a list of owners, which are ``IUser`` objects, instead of
   the single ``contact_address`` they used to have.  ``IUser`` objects now
   also have a ``is_server_owner`` flag (defaulting to False) to indicate
   whether they have superuser privileges.  Give by Abhliash Raj, with fixes
   and refinements by Barry Warsaw.  (LP: #1423756)

 * Domains can now optionally be created with owners; domain owners can be
   added after the fact; domain owners can be deleted.  Also, users now have
   an ``is_server_owner`` flag as part of their representation, which defaults
   to False, and can be PUT and PATCH'd.  Given by Abhilash Raj, with fixes
   and refinements by Barry Warsaw.  (LP: #1423756)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
::
15
15
 
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')
20
20
    ...         return
21
21
    ...     for domain in sorted(manager, key=attrgetter('mail_host')):
22
22
    ...         print(domain)
 
23
    ...     owners = sorted(owner.addresses[0].email
 
24
    ...                     for owner in domain.owners)
 
25
    ...     for owner in owners:
 
26
    ...         print('- owner:', owner)
23
27
 
24
28
    >>> show_domains()
25
29
    no domains
28
32
is the only required piece.  The other parts are inferred from that.
29
33
 
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>
33
36
    >>> show_domains()
34
 
    <Domain example.org, base_url: http://example.org,
35
 
            contact_address: postmaster@example.org>
 
37
    <Domain example.org, base_url: http://example.org>
36
38
 
37
39
We can remove domains too.
38
40
 
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>
42
43
    >>> show_domains()
43
44
    no domains
44
45
 
46
47
web interface for the domain.
47
48
 
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>
51
51
    >>> show_domains()
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>
54
53
 
55
 
Domains can have explicit descriptions and contact addresses.
 
54
Domains can have explicit descriptions, and can be created with one or more
 
55
owners.
56
56
::
57
57
 
58
58
    >>> manager.add(
59
59
    ...     'example.net',
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>
66
 
 
67
 
    >>> show_domains()
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>
 
65
 
 
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
 
71
 
 
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.
 
75
 
 
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
73
83
 
74
84
Domains can list all associated mailing lists with the mailing_lists property.
75
85
::
105
115
 
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>
110
119
 
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.
114
123
 
115
124
    >>> print(manager.get('example.net'))
116
125
    <Domain example.net, The example domain,
117
 
            base_url: http://lists.example.net,
118
 
            contact_address: postmaster@example.com>
 
126
            base_url: http://lists.example.net>
119
127
 
120
128
    >>> print(manager.get('doesnotexist.com'))
121
129
    None