[Mailman-Users] regexp help

Mark Sapiro mark at msapiro.net
Thu Oct 22 05:19:24 CEST 2009


Savoy, Jim wrote:
>
>I just re-read Mark's comments, and he says:
>
>-------
>So assuming that what you want is to bypass the other
>header_filter_rules, you need to "add new item" before the current rule
>1 so the new rule becomes #1. Then the new rule 1 regexp should be
>
>  ^from:.*(\s|<)some\.person\.name at gmail\.com(\s|>|$)
>
>and the action Accept.
>-------
>
>and that is exactly what I want to do - bypass the header_filter_rules.


No, that is not what you want to do. What you want to do is bypass
other non-header_filter_rules holds (i.e. post from non-member) with a
header_filter_rule. You can't do that.

You can do it with accept_these_nonmembers, but not in your case,
because accept_these_nonmembers only works on the From: (or other
'sender' header, not on the To:.


>But I am
>afraid I don't quite understand this advice, Mark. How can I make this
>spam rule
>supercede other rules (like the one that says the list is moderated).


You can't.


>There
>is no "add new item" button when you haven't got any spam rules. That
>only
>comes up when after I create me first rule, which is not superceding the
>moderation
>rule.
>
>I should probably not say anything else until Mark logs in. He's
>probably looking at
>this huge chain and wanting to crack our skulls together like Moe.


It's not your thread - it's the two week backlog of just approved
posts. :)

What you need is a custom handler. See the FAQ at
<http://wiki.list.org/x/l4A9> for how to install one. In your case,
the handler is very simple - just 9 lines.

import re
cre = re.compile('unique\.name', re.IGNORECASE)
def process(mlist, msg, msgdata):
    if mlist.internal_name <> 'abc-l':
        return
    if cre.search(msg.get('to', '')):
        msgdata['approved'] = 1
        # Used by the Emergency module
        msgdata['adminapproved'] = 1


Of course, you adjust the regexp 'unique\.name' and the list name
'abc-l' to suit. The handler needs to be in the pipeline before
Moderate.

If you make a list specific pipeline for just this list, you can leave
out the

    if mlist.internal_name <> 'abc-l':
        return

What this does is nothing if the list isn't abc-l. If it is abc-l and
if the contents of the To: header of the message matches the regexp in
re.compile() case insensitively, then the approved and adminapproved
flags will be set in the message metadata and the message won't be
subject to any holds.

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