[Mailman-Developers] Mailman MySQL adaptor - MySQLdb module error

Aaron Kreider aaron at campusactivism.org
Thu Aug 12 19:02:45 CEST 2010



I found a solution!

Mark Sapiro deserves all the credit for helping me out a TON
=)

Here is my documentation in the hope that it will help someone in the future.



---------------------------


Mark writes:
The basic problem is that the python library or at least the one
containing the site-packages/ into which MySQLdb was installed is
/usr/lib64/python2.4 rather than /usr/lib/python2.4.

Mailman starts a lot of Python processes with the -S option which
bypasses importing the site module at startup and this is what
normally puts the path to site-packages in sys.path. Mailman attempts
to do this itself in its own paths module which everything imports,
but it assumes the path begins with /usr/lib/pythonv.v so it never got
/usr/lib64/python2.4/site-packages into sys.path.

The bit added to extend.py does this when it replaces the
MemberAdaptor, so MysqlMemberships can successfully import MySQLdb.



--------------------------
Aaron adds:

We changed extend.py to be:

import sys
if '/usr/lib64/python2.4/site-packages' not in sys.path:
     sys.path.append('/usr/lib64/python2.4/site-packages')

from Mailman.MysqlMemberships import MysqlMemberships

def extend(list):
         list._memberadaptor = MysqlMemberships(list)




--------------------------

To track down the fact that the module's directory was wrong we had to fix a bug in Mailman's error logging:

There is a bug in the error logging code in
/usr/local/cpanel/3rdparty/mailman/scripts/driver

Edit that file. Find

def print_environment(logfp=None):
     if logfp is None:
         logfp = sys.__stderr__

     try:
         import os
     except ImportError:
         os = None

     # Write some information about our Python executable to the log
file.
     print>>  logfp, '[----- Python Information -----]'
     print>>  logfp, 'sys.version     =', sys.version
     print>>  logfp, 'sys.executable  =', sys.executable
     print>>  logfp, 'sys.prefix      =', sys.prefix
     print>>  logfp, 'sys.exec_prefix =', sys.exec_prefix
     print>>  logfp, 'sys.path        =', sys.exec_prefix
     print>>  logfp, 'sys.platform    =', sys.platform


Change the next to last line of that from

     print>>  logfp, 'sys.path        =', sys.exec_prefix

to

     print>>  logfp, 'sys.path        =', sys.path

and then see what's reported for sys.path in the traceback.

---------------------------


Finally because my Cpanel installation of mailman was creating mailing lists that had "." in their name, and MySQL does not create tables with a period in the name I modified the code for MysqlMemberships.py

A global replace of

   self.__mlist.internal_name()

with

   self.__mlist.internal_name().replace('.', '_')











More information about the Mailman-Developers mailing list