[Mailman-Developers] More extend.py questions

Martin Whinnery <martin.whinnery@sbc.ac.uk> e008993@cobalt.sbirmc.ac.uk
Fri Nov 1 15:01:14 2002

On Wed, 30 Oct 2002, Greg Ward wrote:

> On 30 October 2002, Martin Whinnery said:
> > Please indulge a python virgin. Barry has advised someone to 'overload
> > the Load & Save function' in extend.py . Would someone help me with a
> > little sample? It doesn't need to do anything useful, just replace the
> > original function.
> Huh?  There's no file called extend.py in the Mailman source tree.  Just
> what are you trying to accomplish?

And I quote (From NEWS 2.36)
    - Membership Adaptors
        o Internally, mailing list memberships are accessed through a
          MemberAdaptor interface.  This would allow for integrating
          membership databases with external sources (e.g. Zope or
          LDAP), although the only MemberAdaptor currently implemented
          is a "classic" adaptor which stores the membership
          information on the MailList object.
    - 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...

Now after a little more digging (And I take your point about not hacking
the actual source, I don't know what I was thinking. Probably why I'm
'just the assistant') it appears that what I need to do is implement new
Load() and Save() functions ( orginally defined in MailList.py ), which
cause membership information to be read into the mlist structure from LDAP
rather than from config.pck, and which fail to write that information back
to config.pck.

Or rather, (after more digging), Save() should remove all the membership
information from the MailList instance before calling the original Save(),
and Load should call the original Load() then replace any membership
information with info taken from LDAP.

I appreciate that this will leave membership options unable to be changed,
but that's what we want. A later version might be able to write that info
back to LDAP, but there's authentication issues and the matter of schema
definitions, and I don't need to go there just yet.

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.

I just don't understand Python/Mailman well enough.

--------- My efforts so far -------------
# /usr/local/mailman/lists/ldaplist/extend.py

def extend(mlist):
	mlist.OldSave = mlist.Save
	def MySave(self):
		print "WOOKIE" # So I can see it in withlist
	mlist.Save = MySave

-------- snip snip ----------------------

But when I try m.Save(m) from within "withlist ldaplist", I get a
'NotLocked' error:

NotLockedError: <LockFile
137391332: /usr/local/mailman/locks/ldaplist.lock [unlocked: 18000sec]
pid=9172>: None

And at this point I'm pretty well stuck.

Any examples, flames, advice or witticisms will be revered in a darkened

Thanks in advance (I like the desperate sound that makes when I say it)

Martin Whinnery
"Just the" Assistant Network Manager
South Birmingham College