[Mailman-Developers] Updated patch that allows posting authorization for members of other lists

Nathan Neulinger nneul at umr.edu
Thu Mar 13 10:36:11 EST 2003


This patch allows you to specify

+listname

in the accept_these_nonmembers, hold_these_nonmembers, 
reject_these_nonmembers, and discard_these_nonmembers boxes
in the list configuration, and will dynamically include
the members of those lists. 

This is very useful when you have lists that forward to
other lists. 

For example:

	mygroup-leaders
	mygroup-helpers
	mygroup-workers
	
	with

	mygroup-all forwarding to each of the above.

You could put

+mygroup-helpers
+mygroup-workers
+mygroup-leaders

in the accept box for each of those lists, and it will allow any of 
the members of any of the lists to post to the mygroup-all list. Or
similar affect for other configurations.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul at umr.edu
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216
-------------- next part --------------
Index: Mailman/MailList.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/MailList.py,v
retrieving revision 2.104
diff -u -r2.104 MailList.py
--- Mailman/MailList.py	24 Feb 2003 15:37:57 -0000	2.104
+++ Mailman/MailList.py	13 Mar 2003 16:27:41 -0000
@@ -30,6 +30,7 @@
 import socket
 import urllib
 import cPickle
+import string
 
 from cStringIO import StringIO
 from UserDict import UserDict
@@ -1347,3 +1351,64 @@
         if mm_cfg.DEFAULT_SERVER_LANGUAGE not in langs:
             langs.append(mm_cfg.DEFAULT_SERVER_LANGUAGE)
         return langs
+
+
+
+#
+# Added at University of Wollongong by Peter Gray (pdg at uow.edu.au)
+#
+# The idea here is that addresses of the form +listname at domain
+# are actually other mailman lists. The domain must match the
+# domain of the current list.
+ 
+    def expand_sublists(self, old_recipients):
+        """returns an expanded list of the members. (all lowercase)"""
+
+	new_recipients = self.internal_expand_sublists(old_recipients, 0)
+	return new_recipients
+
+    def internal_expand_sublists(self, old_recipients, recursion_depth):
+	   
+	dirty = 0
+	
+	recursion_depth = recursion_depth + 1
+
+	if recursion_depth > 50:
+		# Screw you guys, I'm going home.
+		raise Error.MMListError, self.internal_name()
+		
+	new_recipients = []
+	
+	for full_address in old_recipients:
+		if full_address[0] != '+':
+			new_recipients.append(full_address)
+			continue
+		
+		s = string.split(full_address, '@')
+		local = s[0][1:]
+		domain = None
+		if len(s) >= 2:
+			domain = s[1]
+		if domain != self.host_name:
+			new_recipients.append(full_address)
+			continue
+
+		try:
+			sublist = MailList(local, lock=0)
+		except:
+# Do we mail to the address or raise an exception?
+# For the moment, just treat the address as a real one
+			new_recipients.append(full_address)
+			continue
+	
+		dirty = 1
+		new_member_list = sublist.getMemberCPAddresses(sublist.getRegularMemberKeys() + sublist.getDigestMemberKeys())
+
+		for new_member in new_member_list:
+			new_recipients.append(new_member)
+
+	if not dirty: return new_recipients
+	return self.internal_expand_sublists(new_recipients, recursion_depth)
+
+# End local additions
+
Index: Mailman/Handlers/Moderate.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/Moderate.py,v
retrieving revision 2.13
diff -u -r2.13 Moderate.py
--- Mailman/Handlers/Moderate.py	31 Dec 2002 03:28:41 -0000	2.13
+++ Mailman/Handlers/Moderate.py	13 Mar 2003 16:27:41 -0000
@@ -87,15 +87,15 @@
     else:
         sender = msg.get_sender()
     # From here on out, we're dealing with non-members.
-    if matches_p(sender, mlist.accept_these_nonmembers):
+    if matches_p(sender, mlist.expand_sublists(mlist.accept_these_nonmembers)):
         return
-    if matches_p(sender, mlist.hold_these_nonmembers):
+    if matches_p(sender, mlist.expand_sublists(mlist.hold_these_nonmembers)):
         Hold.hold_for_approval(mlist, msg, msgdata, Hold.NonMemberPost)
         # No return
-    if matches_p(sender, mlist.reject_these_nonmembers):
+    if matches_p(sender, mlist.expand_sublists(mlist.reject_these_nonmembers)):
         do_reject(mlist)
         # No return
-    if matches_p(sender, mlist.discard_these_nonmembers):
+    if matches_p(sender, mlist.expand_sublists(mlist.discard_these_nonmembers)):
         do_discard(mlist, msg)
         # No return
     # Okay, so the sender wasn't specified explicitly by any of the non-member


More information about the Mailman-Developers mailing list