Python CGI Scripting Documentation

V

Vlad Dogaru

Hello,

I would like to learn web scripting with Python (sure, everyone uses
PHP, but I don't like the syntax and Python is more general-purpose
and... well, I guess you people know the advantages better than me).
Where can I get a thorough introduction to both CGI and using Python
for CGI? That includes installing my own web server (at home, for
testing) and starting from scratch (by that I mean I have near null
experience with CGI).

I have tried looking through the source code of MoinMoin, but it's just
too advanced for me -- I simply don't know where to start. Right now,
I'll take any and all suggestions. However, please suggest books or
articles that are up-to-date on Python programming; I'd hate to see
that I'm studying obsolete texts or the like.

Thanks in advance,
Vlad
 
P

placid

Vlad said:
Hello,

I would like to learn web scripting with Python (sure, everyone uses
PHP, but I don't like the syntax and Python is more general-purpose
and... well, I guess you people know the advantages better than me).
Where can I get a thorough introduction to both CGI and using Python
for CGI? That includes installing my own web server (at home, for
testing) and starting from scratch (by that I mean I have near null
experience with CGI).

I have tried looking through the source code of MoinMoin, but it's just
too advanced for me -- I simply don't know where to start. Right now,
I'll take any and all suggestions. However, please suggest books or
articles that are up-to-date on Python programming; I'd hate to see
that I'm studying obsolete texts or the like.

Chapter 12 of Programming Python 2nd Edition by Mark Lutz
 
A

Alex Martelli

Vlad Dogaru said:
Hello,

I would like to learn web scripting with Python (sure, everyone uses
PHP, but I don't like the syntax and Python is more general-purpose
and... well, I guess you people know the advantages better than me).
Where can I get a thorough introduction to both CGI and using Python
for CGI? That includes installing my own web server (at home, for
testing) and starting from scratch (by that I mean I have near null
experience with CGI).

I have tried looking through the source code of MoinMoin, but it's just
too advanced for me -- I simply don't know where to start. Right now,
I'll take any and all suggestions. However, please suggest books or
articles that are up-to-date on Python programming; I'd hate to see
that I'm studying obsolete texts or the like.

In terms of learning, Steve Holden's "Python Web Programming" is still
unbeatable -- it teaches you just enough of the many underlying
technologies, from HTTP to HTML to relational databases, as well as
Python. However, it IS an old version of Python (sigh). But it's very
easy to learn the relatively small enhancements to the Python language
since the time Steve penned his masterpiece... anything that used to
work then still works now, you have better ways to perform many tasks
(particularly thanks to additions to the standard library, and third
party extension modules matured in the meantime) but those are easy to
learn "afterwards" (and meanwhile, a solid understanding of the basics
of, say, HTTP and entity-relation design, will stand you in good stead
for years and years to come!-). Steve's book is really the best you can
get, for "learning" purposes such as yours. However...L

If you insist on getting coverage of the latest and greatest version of
Python, you might want to get the 2nd edition of my "Python in a
Nutshell", due out later this month; it strives to cover Python 2.5
(also due out later this month;-) as well as 2.4 (the still-now current
version, on which the new Nutshel focuses), and does have a chapter
specifically on CGI (not much changed from the first edition's, of
course, since CGI itself has not changed much over the years;-).

To have a look at my book (and just about any other O'Reilly book... and
not just O'Reilly either!) for free, subscribe to O'Reilly's "Safari"
online library -- I believe the first two weeks are free, so, as long as
you cancel in time, you should not have to pay a penny for the
privilege; thus, it may be a good idea (I personally like having access
to said library for searches etc, but that's a separate issue). It will
be a while before the 2nd edition gets online -- but as I said the CGI
part is basically unchanged anyway.

But, talking of web resources...:

A Google search for Python CGI gives you 20 million hits, and quite a
few of those appear to be good tutorials on the subject -- why don't you
give those a try, first? Sure, most of the pages will be using older
versions of Python -- but most of the differences should be of little
importance. One crucial one: you *DO* want to use the cgitb auxiliary
module to get good tracebacks in case of errors, and older sites may not
mention it -- however, that's pretty simple indeed...:

import cgitb; cgitb.enable()

just place this line at the very top of your CGI script (after the
"shebang" line and the docstring, heh:) and you're all set. Any
further info you need for "advanced" usage of cgitb is in one tiny page
at <http://docs.python.org/lib/module-cgitb.html>.


Alex
 
V

Vlad Dogaru

Alex Martelli wrote:
<snip>

Wow, I'm new in the field, but even I know your name. It's truly
inspiring to be aswered to by you. Thank you, all of you, for your
suggestions. I will try to look into the matter using the starting
points you've given me, as well as read more about Django.

Thanks,
Vlad.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top