I found an excellent example that was posted by the F-bot.
Fredrik Lundh     May 26 2000
From: "Fredrik Lundh" <[EMAIL PROTECTED]>
Date: 2000/05/26

richard_chamberl...@ wrote:
> I'm having great difficulties getting Python to work via CGI.

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

the easiest way is to split your CGI module in two parts; use the
following
script as a wrapper, and place the program logic in a separate script
("my-
script.main()" in this case):

#!/usr/bin/env python

import cgi, StringIO, sys, traceback

try:
    import myscript
    myscript.main()
except:
    print "Content-Type:", "text/html"
    print
    file = StringIO.StringIO()
    traceback.print_exc(file=file)
    print "<pre>"
    print cgi.escape(file.getvalue())
    print "</pre>"

> I haven't got access to error logs so I can't look at it that way.

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to