~barry/mailman/lp1423756

« back to all changes in this revision

Viewing changes to src/mailman/handlers/docs/filtering.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:
26
26
A simple filtering setting will just search the content types of the messages
27
27
parts, discarding all parts with a matching MIME type.  If the message's outer
28
28
content type matches the filter, the entire message will be discarded.
 
29
However, if we turn off content filtering altogether, then the handler
 
30
short-circuits.
29
31
::
30
32
 
31
33
    >>> from mailman.interfaces.mime import FilterAction
42
44
    ... """)
43
45
 
44
46
    >>> process = config.handlers['mime-delete'].process
45
 
    >>> process(mlist, msg, {})
46
 
    Traceback (most recent call last):
47
 
    ...
48
 
    DiscardMessage: The message's content type was explicitly disallowed
49
 
 
50
 
However, if we turn off content filtering altogether, then the handler
51
 
short-circuits.
52
 
 
53
47
    >>> mlist.filter_content = False
54
48
    >>> msgdata = {}
55
49
    >>> process(mlist, msg, msgdata)
74
68
    MIME-Version: 1.0
75
69
    <BLANKLINE>
76
70
    xxxxx
77
 
    >>> msgdata
78
 
    {u'isdigest': True}
 
71
    >>> dump_msgdata(msgdata)
 
72
    isdigest: True
79
73
 
80
74
 
81
75
Simple multipart filtering
82
76
==========================
83
77
 
84
 
If one of the subparts in a multipart message matches the filter type, then
85
 
just that subpart will be stripped.
 
78
If one of the subparts in a ``multipart`` message matches the filter type,
 
79
then just that subpart will be stripped.
86
80
::
87
81
 
88
82
    >>> msg = message_from_string("""\
241
235
    >>> try:
242
236
    ...     print("""\
243
237
    ... import sys
244
 
    ... print 'Converted text/html to text/plain'
245
 
    ... print 'Filename:', sys.argv[1]
 
238
    ... print('Converted text/html to text/plain')
 
239
    ... print('Filename:', sys.argv[1])
246
240
    ... """, file=fp)
247
241
    ... finally:
248
242
    ...     fp.close()