[Mailman-Developers] Modifying mailman to filter archived messages

Barry A. Warsaw barry@zope.com
Wed, 17 Jul 2002 16:41:32 -0400


>>>>> "LB" == Laurence Berland <laurence@digitalpulp.com> writes:

    LB> What I'd like mailman to do is trap these strings such as "0:"
    LB> "1:" etc and replace them with something else.  Is there a
    LB> particularl easy way to do this?  If not, where in the code
    LB> could I conceivably do this.  I've been briefly skimming the
    LB> code, and intend to read through quite a bit of it to figure
    LB> all this out, but if anyone could at least point me in the
    LB> right direction it'd make me very happy.

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.

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.

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.

-Barry