CGI Debugging

David Currie davec999 at my-deja.com
Fri May 26 06:25:00 EDT 2000


Hi richard.

> Is there anyway I can get the traceback on to the web page so I know
what's
> happening?

Yeah, there is a way.  Simply import the 'traceback' module at the
beginning of your program and put the whole program in one try..except
statement.  In the except statement include the following line:

traceback.print_exc()

Add in some HTML maybe, so it is displayed correctly.

If there is an error while running the program it will be displayed.
If the traceback does not appear in the result, then chances are you
have a syntax error in your code.  Set a debug mode that allows you to
run the script locally without calling cgi.FieldStorage() and related
stuff, and this should help you debug these errors.

Dave


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list