[Mailman-Users] Moving list archive location

Barry A. Warsaw bwarsaw at cnri.reston.va.us
Mon Aug 23 18:33:36 CEST 1999


>>>>> "SK" == Scott Kinnane <scott.kinnane at prth.pgs.com> writes:

    SK> Yeah, I know - thats what I did, but now the original area for
    SK> the archives is about to be deleted. Is there no easy way to
    SK> update config.db as to where the archives are kept now? I
    SK> think I might have to dig up a hex editor :(

No need to go to /that/ extreme, remember we're talking Python here!
:)

There's two ways to do this, although both require a little bit of
Python hacking.  See the scripts in $prefix/bin for some examples
(BTW, I think this is one very cool feature of Mailman).

First, remember that config.db is really a Python marshal[1] of a
dictionary, and the archive directory is hardcoded into exactly three
entries.  Here's some code to print out those entries for a mailing
list called `stage' on my machine:

-------------------- snip snip --------------------
@anthem[[/export/home/mailman/lists/stage:515]]% python
Python 1.5.2 (#7, Apr 16 1999, 18:24:22)  [GCC 2.8.1] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import marshal
>>> fp = open('config.db')
>>> m = marshal.load(fp)
>>> m['public_archive_file_dir']
'/export/home/mailman/archives/public'
>>> m['private_archive_file_dir']
'/export/home/mailman/archives/private/stage.mbox'
>>> m['archive_directory']
'/export/home/mailman/archives/private/stage'
-------------------- snip snip --------------------

So one approach could be to unmarshal the dictionary, set these three
values to the new location, and then write the marshal back out to
disk.  However, I would suggest popping up a level of abstraction and
use the MailList object, which does the work of managing the config.db 
files, setting locks, etc.

-------------------- snip snip --------------------
@anthem[[/export/home/mailman:522]]% python -i bin/withlist -l stage
Loading list: stage (locked)
>>> m.private_archive_file_dir
'/export/home/mailman/archives/private/stage.mbox'
>>> m.public_archive_file_dir
'/export/home/mailman/archives/public'
>>> m.archive_directory
'/export/home/mailman/archives/private/stage'
-------------------- snip snip --------------------

So in this case, I'd suggest writing a little script to run through
every mailing list (Utils.map_maillists() is a very convenient
function here), changes these three attribute values to the new
location, and the Save()s the mailing list object back to disk.

Here's a completely untested (and unfinished) script that should get
you most of the way there.

-------------------- snip snip --------------------
from Mailman import Utils

def newdir(old_archive_dir):
    # fill this in with your logic
    pass

def hack_paths(mlist):
    m.private_archive_file_dir = newdir(m.private_archive_file_dir)
    m.public_archive_file_dir = newdir(m.public_archive_file_dir)
    m.archive_directory = newdir(m.archive_directory)
    mlist.Save()

Utils.map_maillists(hack_paths, unlock=1, verbose=1)
-------------------- snip snip --------------------

Hope that helps,
-Barry

[1] http://www.python.org/doc/current/lib/module-marshal.html




More information about the Mailman-Users mailing list