~barry/mailman/lp1423756

« back to all changes in this revision

Viewing changes to src/mailman/handlers/docs/file-recips.rst

  • Committer: Barry Warsaw
  • Date: 2015-01-05 01:20:33 UTC
  • mfrom: (7264.4.66 py3)
  • Revision ID: barry@list.org-20150105012033-zdrw9c2odhpf22fz
Merge the Python 3 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    recipients: 7
35
35
 
36
36
 
37
 
Missing file
38
 
============
39
 
 
40
 
The include file must live inside the list's data directory, under the name
41
 
``members.txt``.  If the file doesn't exist, the list of recipients will be
42
 
empty.
43
 
 
44
 
    >>> import os
45
 
    >>> file_path = os.path.join(mlist.data_path, 'members.txt')
46
 
    >>> open(file_path)
47
 
    Traceback (most recent call last):
48
 
    ...
49
 
    IOError: [Errno ...]
50
 
    No such file or directory: u'.../_xtest@example.com/members.txt'
51
 
    >>> msgdata = {}
52
 
    >>> handler.process(mlist, msg, msgdata)
53
 
    >>> dump_list(msgdata['recipients'])
54
 
    *Empty*
55
 
 
56
 
 
57
37
Existing file
58
38
=============
59
39
 
61
41
addresses are returned as the set of recipients.
62
42
::
63
43
 
64
 
    >>> fp = open(file_path, 'w')
65
 
    >>> try:
 
44
    >>> import os
 
45
    >>> file_path = os.path.join(mlist.data_path, 'members.txt')
 
46
    >>> with open(file_path, 'w', encoding='utf-8') as fp:
66
47
    ...     print('bperson@example.com', file=fp)
67
48
    ...     print('cperson@example.com', file=fp)
68
49
    ...     print('dperson@example.com', file=fp)
69
50
    ...     print('eperson@example.com', file=fp)
70
51
    ...     print('fperson@example.com', file=fp)
71
52
    ...     print('gperson@example.com', file=fp)
72
 
    ... finally:
73
 
    ...     fp.close()
74
53
 
75
54
    >>> msgdata = {}
76
55
    >>> handler.process(mlist, msg, msgdata)