[Mailman-Developers] More extend.py questions

Greg Ward gward@python.net
Mon Nov 4 16:43:46 2002

On 30 October 2002, Martin Whinnery <martin.whinnery@sbirmc.ac.uk> said:
> And I quote (From NEWS 2.36)
> ...
>     - List Extensibility
>         o A framework has been added which can be used to specialize
>           and extend specific mailing lists.  If there is a file
>           called lists/<yourlist>/extend.py, it is execfile()'d after
>           the MailList object is instantiated.  The file should
>           contain a function extend() which will be called with the
>           MailList instance...
> "
> def extend(mlist):
>     mlist = LDAPMailList(mlist)
>     mlist.__memberadaptor = LDAPMemberships(mlist)
> ----- snip ----------

It's pretty clear to me that you don't really understand how Python
passes function parameters around; you definitely need to go do some
homework.  Although it's a bit out-of-date, I recommend *Learning
Python* by Mark Lutz and David Ascher.  It worked for me.

> Now, what I want is for the Load() and Save() functions defined in
> MailList.py to be overridden for this list with my own versions.

Right, the rest of your code makes sense.  The problem is that by the
time Mailman passes the mlist object to your extend() function, it has
already instantiated MailList to create mlist.  You *might* be able to
get away with a noxious and vile hack like this:

  def extend(mlist):
      mlist.__class__ = LDAPMailList

but don't tell anyone *I* said you could do that.

Unfortunately, I don't know enough about Mailman's internals to tell you
what the Right Way to do it is.  Sorry.

Greg Ward <gward@python.net>                         http://www.gerg.ca/
I haven't lost my mind; I know exactly where I left it.