469,579 Members | 1,056 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

debug CGI with complex forms

When the form in one HTML is very complex with a lot of fields(input,
button,radio,checkbox etc.), setting the environment is quite
burdernsome, so I usually change the stdout and stderr of the submit
processing script to a file object to see the output directly from that
file. This just can do, but still inconvinient.
Anyone has more suggestions?

Apr 6 '06 #1
1 1170
"Sullivan WxPyQtKinter" <su***********@gmail.com> writes:
When the form in one HTML is very complex with a lot of fields(input,
button,radio,checkbox etc.), setting the environment is quite
burdernsome, so I usually change the stdout and stderr of the submit
processing script to a file object to see the output directly from that
file. This just can do, but still inconvinient.
Anyone has more suggestions?


The extended Python debugger (http://bashdb.sourceforge.net/pydb) has
the ability to give POSIX-style line tracing, and to change the debugger
stdout/stderr to a file you direct it. For example,
pydb --trace --output=/tmp/dbg.log --error=/tmp/error.log my-cgi

Rather than trace the entire CGI, if there is a specific portion that
you want traced that can be done too by changing the CGI. Create a
files called "/tmp/trace-on" and "/tm/trace-off". "/tmp/trace-on" might
contain this:

# Issue debugger commands to set debugger output to
# go to a file, turn on line tracing, and continue
set logging file /tmp/dbg.log
# uncomment the following line if you want to wipe out old dbg.log
# set logging overwrite on
set logging redirect on
set logging on
set linetrace on
continue

and /tmp/trace-off:

# Issue debugger commands to turn off line tracing and continue
set linetrace off
continue

In your CGI (in the above command-line example the CGI was called
"my-cgi") add:

import pydb # needs to be done only once
...
pydb.set_trace("/tmp/trace-on")
# This and subsequent lines will be traced
...
pydb.set_trace("/tmp/trace-off")

Of course modify the file names in the examples above, my-cgi,
/tmp/dbg.log /tmp/trace-on, /tmp/trace-off as appropriate.

I notice that line tracing at present doesn't show the text of traced
lines just the position (file name, line number, and possibly
function/method name). I will probably change this pretty soon in CVS
though.

Finally, I don't know if any of this will help, but I guess if it
doesn't it would be interesting to understand how it fails.

(If my past experience in c.l.p holds here, if nothing else, my having
posted this will at least motivate someone else to give other
method(s). ;-)


Apr 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Eric Robert | last post: by
3 posts views Thread by Bonj | last post: by
6 posts views Thread by Andrew Rowley | last post: by
6 posts views Thread by =?Utf-8?B?RmFiaWFu?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.