[Mailman-Users] "Official" way of altering the available admin options

Matthew Newton mcn4 at leicester.ac.uk
Tue Mar 15 18:58:57 CET 2005


Regarding the message I sent the other day...

On Tue, Mar 08, 2005 at 05:55:00PM +0000, Matthew Newton wrote:
> I'm developing a new Mailman service here, and want to be able to change
> the available list of things that a mail owner/admin can change for
> their list. Some things I can configure from mm_cfg.py, but not
> everything.
> If there is no standard way of doing this, I will probably look at
> writing a patch where there is a list, say mm_cfg.RESTRICT_CHANGES, that
> contains all configuration sections that should not be shown.  Is this
> a good idea?

Please find attached site_hide_list_options.patch that adds a new option
SITE_HIDE_LIST_OPTIONS. Any options given in this list will not be
displayed on the admin pages. Example:


> I would also like to hook into the subscription code to, do at least two
> things: automatically change all addresses with
> s/@le\.ac\.uk$/@leicester.ac.uk/ and to block subscription requests that
> match /@lists\.le(icester)?\.ac\.uk/ (I do not want to allow umbrella
> lists). Is there a standard way, or hook into the code, for doing this
> (on a site-wide basis, not per list)?

Secondly, the attached patch, transform_address_hook.patch, adds a new
hook into the add member routines to allow the address to be changed.
The function is given the supplied address, and should return the new
address, or raise an error. An example for my site, where all addresses
in the domain "le.ac.uk" should be changed to "leicester.ac.uk" is:

def transform_email_address(email):
    (local, domain) = email.split("@", 2)
    if domain == "le.ac.uk":
        domain = "leicester.ac.uk"
    return "@".join([local, domain])

Hope these are useful.



(Please let me know if I should subscribe to the development list, and
send these patches there!)

Matthew Newton <mcn4 at le.ac.uk>

UNIX and e-mail Systems Administrator, Network Support Section,
Computer Centre, University of Leicester,
Leicester LE1 7RH, United Kingdom
-------------- next part --------------
Index: trunk/Mailman/Defaults.py.in
--- trunk/Mailman/Defaults.py.in	(revision 16)
+++ trunk/Mailman/Defaults.py.in	(working copy)
@@ -109,6 +109,10 @@
 # name of the temporary file that the program should operate on.
 HTML_TO_PLAIN_TEXT_COMMAND = '/usr/bin/lynx -dump %(filename)s'
+# Site-wide prohibition from changing certain list options. Adding
+# an option to this list (for example, "owner") will stop the
+# option from being seen in the list admin pages.
Index: trunk/Mailman/MailList.py
--- trunk/Mailman/MailList.py	(revision 16)
+++ trunk/Mailman/MailList.py	(working copy)
@@ -426,6 +426,18 @@
             if hasattr(gui, 'GetConfigInfo'):
                 value = gui.GetConfigInfo(self, category, subcat)
                 if value:
+                    title = None
+                    for item in value[1:]:
+                        if not isinstance(item, TupleType):
+                            if title is not None:
+                                value.remove(title)
+                            title = item
+                        if not isinstance(item, TupleType) or len(item) < 5:
+                            continue
+                        if item[0] in mm_cfg.SITE_HIDE_LIST_OPTIONS:
+                            value.remove(item)
+                        else:
+                            title = None
                     return value
-------------- next part --------------
Index: trunk/Mailman/Cgi/admin.py
--- trunk/Mailman/Cgi/admin.py	(revision 17)
+++ trunk/Mailman/Cgi/admin.py	(working copy)
@@ -1320,12 +1320,13 @@
         # to render the status page.
         for entry in entries:
             fullname, address = parseaddr(entry)
-            # Canonicalize the full name
-            fullname = Utils.canonstr(fullname, mlist.preferred_language)
-            userdesc = UserDesc(address, fullname,
-                                Utils.MakeRandomPassword(),
-                                digest, mlist.preferred_language)
+                address = mm_cfg.transform_email_address(address)
+                # Canonicalize the full name
+                fullname = Utils.canonstr(fullname, mlist.preferred_language)
+                userdesc = UserDesc(address, fullname,
+                                    Utils.MakeRandomPassword(),
+                                    digest, mlist.preferred_language)
                 if subscribe_or_invite:
                     if mlist.isMember(address):
                         raise Errors.MMAlreadyAMember
Index: trunk/Mailman/Defaults.py.in
--- trunk/Mailman/Defaults.py.in	(revision 17)
+++ trunk/Mailman/Defaults.py.in	(working copy)
@@ -114,6 +114,21 @@
 # option from being seen in the list admin pages.
+# Helper function to transform e-mail addresses. Use, for example,
+# when the list is run on a large site such as a university, and
+# two domain names are in use, but people may not realise to
+# subscribe with their proper address.
+# example:
+# transform_email_address('original at secondary.domain.name')
+# ==> original at primary.domain.name
+# default is to return the same address.
+def transform_email_address(address):
+    return address
 # Virtual domains
Index: trunk/Mailman/MailList.py
--- trunk/Mailman/MailList.py	(revision 17)
+++ trunk/Mailman/MailList.py	(working copy)
@@ -931,6 +931,7 @@
             admin_notif = self.admin_notify_mchanges
         # Suck values out of userdesc, and apply defaults.
         email = Utils.LCDomain(userdesc.address)
+        email = mm_cfg.transform_email_address(email)
         name = getattr(userdesc, 'fullname', '')
         lang = getattr(userdesc, 'language', self.preferred_language)
         digest = getattr(userdesc, 'digest', None)

More information about the Mailman-Users mailing list