FFIIMemberAdaptor, the link between the FFII DB and Mailmain
[ FFII Polis ]
What is it?
The FFII maintains in fact two user databases: First of all, there are the mailing lists. You may subscribe yourself to the lists. For example, to subscribe to or unsubscribe from the polis-parl mailing list, you simply have to visit http://lists.ffii.org/mailman/listinfo/polis-parl and enter your email address. However, a separate project database running on !PostgreSQL exists as well. Quite frequently, users are present in both databases. A certain level of synchronization is required.
Since Mailman 2.1, it is possible to integrate an own user database into Mailman by implementing a subclass of the Mailman MemberAdaptor for details). For example, there exists a subclass accessing an LDAP database. Ideally, the !FFIIMemberAdaptor would read and write directly from or to the !PostgreSQL database. For a first step, this seems to advanced though. However, it is at least possible to implement synchronization by subclassing the standard Mailman member database, called OldStyleMemberships.
What can it do?
Currently, the FFIIMemberAdaptor overrides only two of the various OldStyleMemberships methods:
addNewMember is invoked, whenever a new member subscribes to a mailing list. The method checks, whether the given user is already present in the table "mail". If so, a record is created or updated in the table "projhlp", or "subs", respecively.
removeMember is invoked on unsubscription. This method removes matching entries from "projhlp", or "subs". (More precise, the columns "hlplvl", or "sublvl", respectively, are decreased to indicate, that the member is no longer subscribed.)
Both methods invoke their respective superclass implementation, so that the normal Mailman functionality is still preserved.
More should be possible without too much additional effort. For example, passwords could be changed via Mailman. Likewise, the !PostgreSQL database could be the leading instance for providing passwords.
Installation
Assuming, that the !PostgreSQL database is up and running, one only needs to install the Python database API for !PostgreSQL, pypgsql. On Red Hat Linux, this is as simple as typing "yum install postgresql-python". On Debian Linux, you have to install the package python-pgsql. In what follows, I will assume, that this driver is already installed.
Being written in python, the module is installed by simple putting the file FFIIMemberAdaptor.py to some dedicated place, for example /usr/local/lib/python. The top of the module contains a single editable constant, the DSN (datasource name), which must reflect the database host, name, user, and password. For example, it might read
DSN = "localhost:ffii:wiedmann:who?me?"
to match the database "ffii" on host "localhost", accessed as user "wiedmann" with password "who?me?".
Unfortunately, customization of Mailman as a whole isn't supported so much. In other words, the following procedure has to be repeated for any mailing list being synchronized. As an example, I will take "polis-parl". Create a file /home/list/lists/polis-parl/extend.py (Mailman is looking for it), with the following contents:
- import sys sys.path.append("/usr/local/lib/python") from FFIIMemberAdaptor import FFIIMemberAdaptor def extend(self):
- self._memberadaptor = FFIIMemberAdaptor(self)
The first two lines extend the Python search path for modules by adding "/usr/local/lib/python". The third line loads the module. And the last two lines change the MemberAdaptor from the default to an instance of !FFIIMemberAdaptor.
Is that all?
Yes.
