
Hello all,
I am using Mailman v2.1.9 with the LDAPMembership adapter (v 0.6). Mailman has been patched to all me to specify lists in the 'accept_these_nonmembers', 'hold_these_nonmembers', etc. using the @listname notation. Due to the circumstances here, I need to modify the Moderate.py to allow me add an additional list attribute which enables addresses in that attribute to always send to the list. I think I have a handle on that part of the modification.
The problem I am having is if I specify a list with statically defined addresses in the 'accept_these_nonmembers' and the others, messages sent to the list go through with no problems. However, if the list I specify is dynamically built via the LDAPMembership adapter, messages are held for moderation (the generic default action). I put the same people on list whether statically defined or dynamically defined.
I believe I have narrowed down the problem to the 'matches_p' function in Moderate.py.
Anyone feeling lucky enough to answer my questions about Moderate.py and the LDAPMembership adapter.
Thanks, Chris

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?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

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:

C Nulk wrote:
The change you made is correct. The problem is I think I referred you to the original listinclusion.patch from <http://sourceforge.net/tracker/index.php?func=detail&aid=1220144&group_id=103&atid=300103>, and that patch has problems when the MemberAdaptor is other than the default OldStyleMemberships.py.
The current Moderate.matches_p() is attached as matches_p.txt for your reference.
[...]
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 don't know where else you are seeing mlist.members.has_key(variable), but the only place anything like that should be referenced is in OldStyleMemberships.py. Anywhere in the code at large where there is a membership test it should be via the list's isMember() method which will determine membership via the appropriate MemberAdaptor.
Yes, I can look at them.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

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?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

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:

C Nulk wrote:
The change you made is correct. The problem is I think I referred you to the original listinclusion.patch from <http://sourceforge.net/tracker/index.php?func=detail&aid=1220144&group_id=103&atid=300103>, and that patch has problems when the MemberAdaptor is other than the default OldStyleMemberships.py.
The current Moderate.matches_p() is attached as matches_p.txt for your reference.
[...]
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 don't know where else you are seeing mlist.members.has_key(variable), but the only place anything like that should be referenced is in OldStyleMemberships.py. Anywhere in the code at large where there is a membership test it should be via the list's isMember() method which will determine membership via the appropriate MemberAdaptor.
Yes, I can look at them.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (3)
-
C Nulk
-
Chris Nulk
-
Mark Sapiro