[mod_python] How do you use mod_python?

Dave Britton dave at davebritton.com
Wed Jan 18 08:41:39 EST 2006

I currently use mod_python to provide a database-driven web site for a class
I teach at City College. With no concern for fancy presentation issues, the
site needs an easy way to prepare and deliver and grade class assignments
online, in which each student's assignment is personalized (or at least
randomized to be individual). The publisher handler is all I am using at the
moment, since it is easy and works well, although I expect to add Graham's
Vampire system soon for added functionality. Python with mod_python has been
fast, flexible and powerful for this purpose so far. The specific "how" is
pretty vanilla compared to what I read in this list:  1) I like to put the
whole application in one module, different functions of which are called by
each page, so the structure or pattern is 2) to collect the incoming cgi
variables (which is convenient with mod_python), 3) open the database with
MySQLdb, 4) figure out whatever needs figuring out with python code, and 5)
construct the html output string in the process, using forms to pass cgi
intemediate information, especially any session-like page-to-page persistent
information, as hidden variables, with the html form ACTION usually being a
function in the application module. Then 6) close the database and 7) return
the html string and 8) wait for the user to fill in a form and/or click a
form button on the delivered page so we can do it all again.

I've done several other web-based applications in this fashion before. One
particularly useful aspect of it is the ability to dynamically create
complex javascript when required. Another application used mod_python in
combination with ZSI SOAP to dynamically deliver an application that ran on
the local webserver but enabled retrieval and update of a remote vendor's

I'm using older versions of apache and mod_python (1.3/2.7) for this current
classroom application because I haven't gotten the spacetime to upgrade
(I've been through that process before and it isn't easy enough to take
lightly) so fancy modern conveniences like Session are still in the future.

I'm starting a new application to manage a huge database of neurophysiology
research data which may involve figuring out how to do things like database
connection pooling and running lengthy background processing jobs (possibly
on other machines) that will let you check their status and control them by
web page.

Overall the "how I use mod_python" answer is to stay straight up out of the
box, no messing with it, try to zen out what it likes to do and use it that

----- Original Message ----- 
From: "Daniel Nogradi" <nogradi at gmail.com>
To: <mod_python at modpython.org>
Sent: Wednesday, January 18, 2006 6:50 AM
Subject: [mod_python] How do you use mod_python?

> Some time ago there was a post (I think by Grisha) asking "why are you
> using mod_python?". It would be interesting to see answers from many
> users to a related question, _how_ do you use mod_python?
> A little more specifically, the various ways of using mod_python that
> I have in mind (which list is very much limited by my knowledge)
> include
> (1) writing custom handlers for every new project
> (2) writing a universal handler which serves various unrelated projects
> (3) using the publisher handler for every project
> (4) tweaking the publisher handler for every new project in different ways
> (5) using the publisher for some of the projects but writing new
> handlers for others
> And of course there could be many more ways of using mod_python that
> just didn't come into my mind at the moment or don't even know about
> it.
> So, after all, how do you use mod_python?
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list