[Mailman-Developers] Modifying mailman to filter archived messages

Laurence Berland laurence@digitalpulp.com
Tue, 23 Jul 2002 11:43:43 -0400


On Wednesday 17 July 2002 04:41 pm, Barry A. Warsaw wrote:
> A general approach would be to hack into the
> Mailman/Queue/ArchRunner.py file, ArchRunner._dispose() method.  I'd
> write a separate "handler module", say
> Mailman/Handlers/OurStatusMunger.py which does the specifics of the
> transformation you're interested in.  Although your situation is
> fairly unique, you might want to copy the API and style of other
> handler modules in that directory.

I'm using mailman 2.0.11 and can't seem to find the file ArchRunner.py, or 
even a Queue directory for that matter.  Is this because my version is too 
old/new?  Where would I find this in 2.0.11, or should I just upgrade and 
port the work I've already done over?  If so, what version should I upgrade 
to, keeping in mind this code needs to actually be used in production in the 
near future, so beta (2.1?) isn't necessarily a good idea.

>
> Then add something to _dispose() that checks an attribute on the mlist
> object to decide whether to call into your handler module.  I'd do the
> check like this:
>
>     ...
>     from Mailman.Handlers import OurStatusMunger
>     ...
>     if getattr(mlist, 'munge_status_p', 0):
> 	OurStatusMunger.process(mlist, msg, msgdata)
>     ...
>
> and then use bin/withlist to add this attribute (set to 1 of course!)
> to just the list you want to do the extra processing on.

I've added a few config flags instead.  When I finish with all this, is there 
any interest in adding it back in to the mailman source?  It offers three 
configurable parameters for archives.  Regex filtering on/off, regex pattern, 
replacement pattern.  I can think of a few interesting uses offhand, namely 
variable spam armoring, automatic filtering of obscenity (if it's a list for 
children or something, I don't want to claim to generally advocate that sort 
of thing), gratuitous substitution of phrases (I know some people who'd love 
to always replace "Microsoft" with "the evil whose name one dares not speak" 
in every message...), etc.

>
> Note that if you want to do this /before/ the message hits the
> archiver, e.g. you want it in the outgoing messages, you'd simply need
> to add the OurStatusMunger module to the GLOBAL_PIPELINE variable in
> Defaults.py.in -- another good reason to make OurStatusMunger.py
> conform to the handler API.
>
I'm trying to conform, and hopefully someone will be willing to glance over 
stuff when I'm done and tell me if I have conformed sufficiently, and if not 
what changes I need make.

Thanks again for the extensive help,
Laurence