FAQ
Greetings... I'm installing a new virtual mail server using Debian
Sarge, PostgreSQL, Postfix, Dovecot, Mailman, and PostfixAdmin. I'm
trying to automate/tie as much of the administrative configuration
into the PostfixAdmin web interface & PostgreSQL database as
possible. The only thing in the entire setup that doesn't have
direct query access to the SQL database is Mailman. What I want to
do is create an hourly cron job to run a script which pulls the names
of the virtual domains from the database and creates the necessary
addvirtualhost('lists.%s', 'lists.%s') configuration items in
mm_cfg.py. If I end up needing to use a new domain for mailing lists
more quickly than an hour, I can just run the script manually.

I figure that the easiest way to do that would be to have the script
put those configuration items in a separate file and just use
something like Apache's "Include" directive to read it into the
configuration.

I'm not terribly familiar with Python programming, and the only thing
I can find that's similar to what I want to do is the "import"
command. It's not working like I'd hoped because when I add a "from
vhosts_cfg import *" to mm_cfg.py, the Mailman web scripts just come
back with "We've found a bug!" errors and nothing shows up in
/var/log/mailman/error. I did remember to create an
/etc/mailman/vhosts_cfg.py test file with correct addvirtualhost()
usage syntax and made a symlink to it in /var/lib/mailman/Mailman, so
it shouldn't be a matter of a missing file.

I'm not sure what I'm missing or even if this is the best way to
accomplish the task, and rather than go through the time-consuming
task of learning the semantics of another programming languate, I
figured I'd ask the experts. :) If anyone knows of a good way to do
this, I'd greatly appreciate a heads-up. If this ends up being some
sort of informal feature request to be included in the next latest
and greatest version, that'd be cool too. Thanks in advance for any
help offered!

--

Scott 'Simba' Garron

Search Discussions

  • Mark Sapiro at Apr 27, 2006 at 5:21 am

    simba at vmailtest.ao.net wrote:
    I'm not terribly familiar with Python programming, and the only thing
    I can find that's similar to what I want to do is the "import"
    command. It's not working like I'd hoped because when I add a "from
    vhosts_cfg import *" to mm_cfg.py, the Mailman web scripts just come
    back with "We've found a bug!" errors and nothing shows up in
    /var/log/mailman/error. I did remember to create an
    /etc/mailman/vhosts_cfg.py test file with correct addvirtualhost()
    usage syntax and made a symlink to it in /var/lib/mailman/Mailman, so
    it shouldn't be a matter of a missing file.

    import is not include

    You can't just put an add_virtualhost('a','b') line in a file and
    import it into mm_cfg.py, because 'add_virtualhost' is undefined in
    the file you're importing.

    You don't get an error log entry because the traceback logging in
    scripts/driver does this

    try:
    from Mailman.mm_cfg import VERSION
    except ImportError:
    VERSION = '<undetermined>'

    but when you have syntax or other errors occurring in the import, the
    exception thrown is not ImportError and the whole thing dies right
    there. You might find the error in the web server's error log.

    To actually see what the problem is, do

    cd /var/lib/mailman/Mailman
    python
    import mm_cfg
    And you'll see the errors. This won't necessarily tell you what to do,
    but it will tell you what you can't do.

    --
    Mark Sapiro <msapiro at value.net> The highway is for gamblers,
    San Francisco Bay Area, California better use your sense - B. Dylan
  • Scott Garron at Apr 27, 2006 at 8:41 pm

    You can't just put an add_virtualhost('a','b') line in a file and
    import it into mm_cfg.py, because 'add_virtualhost' is undefined in
    the file you're importing.
    Makes sense. I was able to get it working by simply adding "from
    Defaults import add_virtualhost" to the top of my vmail_cfg.py file.
    Thanks for your input!

    --
    Scott 'Simba' Garron

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmailman-users @
categoriespython
postedApr 27, '06 at 4:15a
activeApr 27, '06 at 8:41p
posts3
users2
websitelist.org

2 users in discussion

Scott Garron: 2 posts Mark Sapiro: 1 post

People

Translate

site design / logo © 2022 Grokbase