[Mailman-Users] A scrubber issue
Mark Sapiro
msapiro at value.net
Sat Dec 9 20:09:23 CET 2006
Tokio Kikuchi wrote:
>
>This program prints out like this:
>
>multipart/mixed
>None
>text/plain
>text/plain
>Another text with a header
>
>Note that 'A message without header' is not printed out.
>
>If I remove 'If p:' and print the payload unconditionally, I get:
>
>multipart/mixed
>None
>text/plain
>A message without header
>
>text/plain
>Another text with a header
>
>Here, the no-header part is printed out.
The problem is that the 'truth' of an object that has a __len__()
method is "__len__() <> 0", and the __len__() method of an
email.Message object returns the number of headers.
One possible fix is to define a Message.__nonzero__() method in either
email.Message or Mailman.Message.Message as
def __nonzero__(self):
"""Return True if the message has any headers or payload."""
return len(self._headers) + len(self._payload)
since a __nonzero__() method seems to take precedence over a __len__()
method in determining the truth of an object.
Another possible fix in Scrubber.py is to change
for part in msg.walk():
# TK: bug-id 1099138 and multipart
if not part or part.is_multipart():
to:
for part in msg.walk():
# TK: bug-id 1099138 and multipart
if not part.get_payload() or part.is_multipart():
--
Mark Sapiro <msapiro at value.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
More information about the Mailman-Users
mailing list