[Tutor] Python and Apache (OT)

Emil Styrke emil@lysator.liu.se
Mon Apr 28 17:35:10 2003


Roger Merchberger <zmerch@30below.com> writes:

> At least as far as I can tell, tho, Python as a CGI scripting engine
> isn't as versatile as Perl.
>
> Now, lemme quantify that: I set up mod_python per the instructions,
> and from everything that I've learned as a beginner at Python & a
> fairly knowledgeable Linux geek & web admin, Apache's configuration of
> mod_python only sets a single named script as a viable python CGI
> program, or if there is a way of having multiple python CGI scripts in
> one config, there's /no/ documentation as to how to set that up.

Actually, there is.  It might look a little cryptic to those used to
regular CGI:s though, due to the fact that mod_python isn't really
meant for CGI:s at all.  Take a look at
http://www.modpython.org/live/mod_python-2.7.8/doc-html/hand-cgi.html
for how to use mod_python for CGI:s.

You might also be interested in
http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.004.htp

If you just want different handlers in different directories, you can
create .htaccess files or use <Location> sections in your apache
config.

> If you tell Apache that you want script.py as your CGI, that's all you
> get. If you can tell Apache that *.py should all be run, Google can't
> find it, and every "wildcard" permutation I've tried in my httpd.conf
> file resulted in Apache barfing & refusing to start.
> What do I do when I want a guestbook.py, a forsale.py & wantlist.py?
> Usually code it in Perl or ColdFusion.

I've never used mod_perl, but after a quick look in the docs, I can't
really see the difference between the two.  You can still only have
one script per directory, designated by the "PerlResponseHandler"
directive.  Using the ModPerl::Registry handler is the equivalent of
mod_python.cgihandler.

        /Emil