[Mailman-Users] Automate Moderator Functions

Mark Sapiro mark at msapiro.net
Wed Oct 3 02:46:20 CEST 2012


Dennis Putnam wrote:
>
>I am getting back to this and I have a question about maintenance. What
>is the correct way to modify this so that it will not get destroyed by
>updates?


There are two ways to proceed.

You can modify Mailman/Handlers/Hold.py itself, but before overwriting
it, make a "diff -u" between the base Hold.py and your modified
version to use as a patch to apply after any upgrade.

A better way is to leave Hold.py unchanged and make your own edited
version as say Mailman/Handlers/MyHold.py. Then you can replace the
base Hold.py Module with your MyHold.py by putting

GLOBAL_PIPELINE[GLOBAL_PIPELINE.index('Hold')] = 'MyHold'

in mm_cfg.py. Note that if you are going to do this, and you want also
to move MimeDel before Hold, you must either put the above line after
the lines

GLOBAL_PIPELINE.remove('MimeDel')
GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('Hold'), 'MimeDel')

in mm_cfg.py or put it before, but then also change

GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('Hold'), 'MimeDel')

to

GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('MyHold'), 'MimeDel')

I recommend the former as in

#
# Put MimeDel ahead of Hold so "too big" is based on content filtered
# message.
#
GLOBAL_PIPELINE.remove('MimeDel')
GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('Hold'), 'MimeDel')
#
# Replace Hold with local version
#
GLOBAL_PIPELINE[GLOBAL_PIPELINE.index('Hold')] = 'MyHold'

Since mm_cfg.py survives upgrades, this should survive.


>Also does this same procedure apply to other automatic rejections such
>as implicit destination?

>On 9/24/2012 8:43 PM, Mark Sapiro wrote:
>>
>> To automatically reject or discard messages that exceed the list's size
>> limit, find the section of the Mailman/Handlers/Hold.py that ends with
>> the lines
>>
>>
>>         if bodylen/1024.0 > mlist.max_message_size:
>>             hold_for_approval(mlist, msg, msgdata,
>>                               MessageTooBig(bodylen,
>> mlist.max_message_size))
>>             # no return
>>
>> (there is one wrapped line in the above) and replace
>>
>>             hold_for_approval(mlist, msg, msgdata,
>>                               MessageTooBig(bodylen,
>> mlist.max_message_size))
>>
>> with
>>
>>             rej = MessageTooBig(bodylen, mlist.max_message_size))
>>             raise Errors.RejectMessage, rej.reason_notice
>>
>> to reject the message or with
>>
>>             raise Errors.DiscardMessage
>>
>> to discard the message. Note that this will not honor the list's
>> forward_auto_discards setting. to do that you would need to put
>>
>> from Mailman.Handlers.Moderate import do_discard
>>
>> with the other imports near the beginning of the
>> Mailman.Handlers.hold.py module and then replace the lines with
>>
>>             do_discard(mlist, msg)


Yes, similar changes would apply to other holds in Hold.py.

-- 
Mark Sapiro <mark at msapiro.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