[Mailman-Developers] Problem with Moderate.py

C Nulk CNulk at scu.edu
Mon Sep 28 22:33:12 CEST 2009


Hello Mark,

I am posting the matches_p function below.  I believe the problem is an
off-shoot of the lce/cpe problem with the LDAPMembership adapter you
helped me with earlier.  I did get it to work by changing the condition
in matches_p from

     if mother.members.has_key(sender):
to
    if mother.isMember(sender):

It works for both statically created lists and the ldap dynamically
created lists.

Here is the complete matches_p function (from Mailman v2.1.9 with the
@list patch applied and my changes):

def matches_p(sender, nonmembers):
    # First strip out all the regular expressions
    plainaddrs = [addr for addr in nonmembers if not addr.startswith('^')]
    addrdict = Utils.List2Dict(plainaddrs, foldcase=1)
    if addrdict.has_key(sender):
        return 1
    # Now do the regular expression matches
    for are in nonmembers:
        if are.startswith('^'):
            try:
                cre = re.compile(are, re.IGNORECASE)
            except re.error:
                continue
            if cre.search(sender):
                return 1
        elif are.startswith('@'):
        try:
            mother = MailList(are[1:], lock=0)
            # Changed the condition to use the list's isMember method
--CN  28-Sep-2009
            # if mother.members.has_key(sender.lower()):
            if mother.isMember(sender):
                return 1
            except Errors.MMUnknownListError:
                syslog('error', 'filter references non-existent list %s',
                        are[1:])
    return 0


Is the change I made the correct way of fixing the problem?  If so,
should other places where 'mlist.members.has_key(variable)' also be changed?

I have also added the 'accept_special_posters' attribute I mentioned on
the Mailman-users list.  Can you take at least a quick look at the
changes to make sure I didn't mess things up to bad?  I have the diffs
for MailList.py, versions.py, Version.py, Gui/Privacy.py and
Handler/Moderate.py.

Thanks for your help, Mark.

Chris




Mark Sapiro wrote:
> Chris Nulk wrote:
>   
>> I believe I have narrowed down the problem to the 'matches_p' function in Moderate.py.
>>     
>
> Can you post your matches_p definitiopn?
>
>   


More information about the Mailman-Developers mailing list