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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
==============
Adding members
==============
You can add members to a mailing list from the command line.
>>> mlist = create_list('test@example.com')
>>> class FakeArgs:
... filename = None
... listname = None
>>> args = FakeArgs()
>>> from mailman.commands.cli_members import Members
>>> command = Members()
To do so, you need a file containing email addresses and full names that can
be parsed by email.utils.parseaddr().
>>> addresses = [
... ]
>>> import os
>>> path = os.path.join(config.VAR_DIR, 'addresses.txt')
>>> with open(path, 'w') as fp:
... for address in ('aperson@example.com',
... 'Bart Person <bperson@example.com>',
... 'cperson@example.com (Cate Person)',
... ):
... print >> fp, address
>>> args.filename = path
>>> args.listname = [mlist.fqdn_listname]
>>> command.process(args)
>>> sorted(address.address for address in mlist.members.addresses)
[u'aperson@example.com', u'bperson@example.com', u'cperson@example.com']
You can also specify '-' as the filename, in which case the addresses are
taken from standard input.
>>> from StringIO import StringIO
>>> fp = StringIO()
>>> for address in ('dperson@example.com',
... 'Elly Person <eperson@example.com>',
... 'fperson@example.com (Fred Person)',
... ):
... print >> fp, address
>>> fp.seek(0)
>>> import sys
>>> sys.stdin = fp
>>> args.filename = '-'
>>> command.process(args)
>>> sys.stdin = sys.__stdin__
>>> sorted(address.address for address in mlist.members.addresses)
[u'aperson@example.com', u'bperson@example.com', u'cperson@example.com',
u'dperson@example.com', u'eperson@example.com', u'fperson@example.com']
Blank lines and lines that begin with '#' are ignored.
>>> with open(path, 'w') as fp:
... for address in ('gperson@example.com',
... '# hperson@example.com',
... ' ',
... '',
... 'iperson@example.com',
... ):
... print >> fp, address
>>> args.filename = path
>>> command.process(args)
>>> sorted(address.address for address in mlist.members.addresses)
[u'aperson@example.com', u'bperson@example.com', u'cperson@example.com',
u'dperson@example.com', u'eperson@example.com', u'fperson@example.com',
u'gperson@example.com', u'iperson@example.com']
Addresses which are already subscribed are ignored, although a warning is
printed.
>>> with open(path, 'w') as fp:
... for address in ('gperson@example.com',
... 'aperson@example.com',
... 'jperson@example.com',
... ):
... print >> fp, address
>>> command.process(args)
Already subscribed (skipping): gperson@example.com
Already subscribed (skipping): aperson@example.com
>>> sorted(address.address for address in mlist.members.addresses)
[u'aperson@example.com', u'bperson@example.com', u'cperson@example.com',
u'dperson@example.com', u'eperson@example.com', u'fperson@example.com',
u'gperson@example.com', u'iperson@example.com', u'jperson@example.com']
Displaying members
==================
With no arguments, the command displays all members of the list.
>>> args.filename = None
>>> command.process(args)
aperson@example.com
Bart Person <bperson@example.com>
Cate Person <cperson@example.com>
dperson@example.com
Elly Person <eperson@example.com>
Fred Person <fperson@example.com>
gperson@example.com
iperson@example.com
jperson@example.com
|