Debug python CGI

François Pinard pinard at iro.umontreal.ca
Sat Jan 26 16:24:40 EST 2002


[Sheila King]

> > Cool, it works! Thanks!
> > however is a UNIX newbie finds this in a Google search he should use
> > 
> > echo -n 'x=y&z=t' | REQUEST_METHOD=POST python acgi.py
> > 
> > instead of 

> YEAH!  THIS suggestion above worked for me.  I was fiddling around with
> Alex's suggestions (and variations thereon) and had not been successful
> until this latest suggestion by Steven.

I found very useful at times, for debugging CGI scripts over complex HTML
forms, having the script to save something similar to the above into a
file, that can later be executed as a stand-alone script.  This has been
very welcome for complex HTML form, as the `echo' may be rather heavy to
type in.  I was also saving a bit more from the environment, because the
CGI script wanted more.  This allowed me to debug CGI scripts more directly,
with more usual ways, outside any browser.

Later, once the whole thing in production, in case of any problem, a message
gets sent to the maintainer with the same information, and much more details.
This has proven very useful.  A ConfigParser switch may be used so the
CGI script writes the debugging information into the browser instead of
sending a message.  In production, we prefer displaying a polite message
to the user, rather than a lot of technical details that would be mere noise.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list