[Mailman-Developers] Listen to or hook into mailman subscriptionsystem

Mark Sapiro mark at msapiro.net
Thu May 27 17:43:02 CEST 2010


Bibek Shrestha wrote:
>
>If i have to hook into user's subscriptions (new/edit/remove) and then
>perform specific non mailman related activities, how do I go about it?


Barry has answered for MM3. For MM 2.1, there are no hooks for this
built in. You would have to add your own.

The most elegant way to do this would be create your own MemberAdaptor
as a subclass of whatever MemberAdaptor you are currently using.
Mailman by default uses OldStyleMemberships.OldStyleMemberships which
itself is a subclass of the generic MemberAdaptor.MemberAdaptor class.

You could create MyMemberAdaptor.py in the Mailman/ directory to contain

from Mailman import OldStyleMemberships

class MyMemberAdaptor(OldStyleMemberships.OldStyleMemberships):

and then override those methods you want to hook into.

Then, there are a couple of ways to enable this MemberAdaptor. To
enable it for one or a few lists, place a file named extend.py in the
lists/LISTNAME/ directory for the list(s). This file contains

from Mailman.MyMemberAdaptor import MyMemberAdaptor
def extend(mlist):
    mlist._memberadaptor = MyMemberAdaptor(mlist)

To enable it for all lists, you could patch MailList.py, adding

from Mailman.MyMemberAdaptor import MyMemberAdaptor

and changing

        # Default membership adaptor class
        self._memberadaptor = OldStyleMemberships(self)

to

        # Default membership adaptor class
        self._memberadaptor = MyMemberAdaptor(self)


-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Developers mailing list