[Tutor] Python and Apache (OT)

Roger Merchberger zmerch@30below.com
Mon Apr 28 00:47:02 2003

At 21:05 04/25/2003 -0700, you wrote:
>On 25/4/2003, Isaac Hall wrote:
> >he states something to the effect that he thinks
> >python is not very widely used for cgi scripting, however it is my
> >understanding that python works very well for cgi scripting, and is
> >widely used for that purpose.
>As a python beginner who wants to do some cgi things, I have to agree
>with the author on this point.  Perhaps python is widely used for cgi,
>but if so, those programmers aren't sharing their work.  I'm not
>talking about frameworks here, I have no desire for frameworks, just
>simple everyday cgis.  Last month I went out looking for examples to
>study, and while I could easily find thousands of cgis written in perl,
>the available python cgis were in the tens.  Not even the hundreds.
>Many of those were years old, and badly needed fixing and/or
>modernization.  I realize that most of the thousands of perl cgis are
>garbage (buggy, no security, etc), and many of the rest are near clones
>of each other, but for any type of web task (form manager, log
>analysis, chat room, database, search engine, etc) there seem to be at
>least three or four excellent ones to choose from.  Python has a long
>way to go to fill in those gaps.

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.

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.

Oh, and WRT your mention of lack of security in a lot of perl CGIs out 
there -- I do agree, but setting up a wildcard *.cgi to run from a non-CGI 
directory is a big security hole in itself, so that's why I wanted another 

>By the way, I'm constantly amused by anyone not liking indentation and
>lack of braces on first sight.  It was largely that that made me want
>to drop my tussling with perl for python about 30 seconds after
>accidentally running into some python source.  It was only afterwards
>that I found the even better goodies, such as decent list manipulation.

To each his own. I'm constantly amused by people who are amazed that not 
everyone fits into their worldview. I personally much prefer /stated/ loop 
boundries (while/wend; if/else/endif; for/next) but braces aren't a problem 
either -- and I'll be the first to admit that the indentation is less 
difficult than I'd thought to become accustomed to (well, once I reconfiged 
my editor to quit converting spaces to tabs...)

I can honestly say that it took me no less time to start hacking usable 
proggies in Perl than it did in Python. Admittedly, I had better 
documentation for Perl, so that's a testament to Python, but I've also got 
8 more years of experience under my belt, and hacking an unknown language 
in many ways has gotten easier... Flip a coin...


I'm not giving up on Python (as I have with PHP...) but personally, I don't 
think that mod_python is quite ready for prime-time as a CGI scripting 
mega-powerhouse. I honestly hope that this changes soon, and when it does, 
I will switch! But until then, I just can't put Perl on the back burner...

Just my Python noobie $0.02,
Roger "Merch" Merchberger