[Mailman-Users] Moving list archive location

Scott Kinnane scott.kinnane at prth.pgs.com
Tue Aug 24 04:40:25 CEST 1999


Genius Barry .... well its more that out of the dozen or so programming
languages I'd learnt Python wasn't one of them, so thank god you have. I
think I'll have to change that fact though.

Anyway, I used your example of "withlist" below, wrote a wrapper shell
script, and in about 5 minutes had the 8 or 9 mailing lists working out
of the correct directory.

Thanks so much for you help Barry.

For those that are interested, here's what I did to convert them
(Warning: theres NO error cecking here - I just wanted it to work, not be
"correct"). Make sure you do this as your mailman user. And yes, it
should be m.Save, not mlist.Save.

---snip---
#!/bin/sh

newroot='/local/apps/mailman-1.0/SunOS/5.6'

for list in `ls $newroot/lists`
do
python -i $newroot/bin/withlist -l $list <<EOF
m.private_archive_file_dir
m.private_archive_file_dir='$newroot/archives/private/$list.mbox'
m.public_archive_file_dir
m.public_archive_file_dir='$newroot/archives/public'
m.archive_directory
m.archive_directory='$newroot/archives/private/$list'
m.Save()
EOF
done
---snip---

scott

"Barry A. Warsaw" wrote:

> >>>>> "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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scott.kinnane.vcf
Type: text/x-vcard
Size: 413 bytes
Desc: Card for Scott Kinnane
Url : http://mail.python.org/pipermail/mailman-users/attachments/19990824/0ca6a19c/attachment.vcf 


More information about the Mailman-Users mailing list