[Mailman-Users] Topics and friendly rejections of topicless messages

Mark Sapiro mark at msapiro.net
Sat Apr 2 20:01:38 CEST 2011


Patti Beadles wrote:

>I'm trying to set up a list with the topics feature, and I'm
>having a little bit of trouble achieving what I want.  The
>basic feature is fine, but making it a smooth user experience
>is being problematic.  In particular, what I want is this:
>
>A) Allow topic-based list subscription
>B) Every message must have a topic
>C) Messages that don't have a topic get bounced back to the user
>D) The bounced messages must be "pretty", and explain what to do
>
>A was easy enough.


Congratulations. Was the FAQ at <http://wiki.list.org/x/G4CE> helpful?
Did you even see it?


>I implemented B and C by using spam filtering, and setting the
>spam filter to bounce mail whose subject line matches a regular 
>expression.  That regex is essentially "not (topic1 | topic2)".
>That solution is functional, if not particularly elegant.
>
>Item D is throwing me for a loop.  I can make it happen with a
>one-line change to SpamDetect.py, but that's probably not going
>to fly.  The host runs multiple lists, and doing this would 
>constrain the other lists in ways that aren't really acceptable.


I think a better solution to B, C and D. is a custom handler. A custom
handler can be enabled for only a single list and should therefore be
acceptable to the host. See the FAQ at <http://wiki.list.org/x/l4A9>
for information about custom handlers.

The place in the pipeline for this particular handler is between Tagger
and CalcRecips.

The handler itself can be quite simple:

------------------------------------------------------
from Mailman.Errors import RejectMessage

NOTICE = """Some nice text for
the rejection message.
"""

def process(mlist, msg, msgdata):
    if not mlist.topics_enabled:
        return
    if not msgdata.get('topichits'):
        raise RejectMessage(NOTICE)
------------------------------------------------------


-- 
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