[mod_python] PythonDebug and Traceback

Mike Looijmans mike.looijmans at asml.com
Wed Aug 27 07:21:05 EST 2003


>Is there some way that you can have PythonDebug set to Off and still get
>a traceback (I'm using 2.7.8 mod_python against python 2.2.2)?

Sure, but you'll have to display it yourself. My script usually look like
this:

req.content_type="text/html"
writeheader(req, mytitle . . .)
try:
   # do some stuff (like connecting to the DB)
except:
   printexception(req)
printfooter(req, . . .)


--
The printexception() routine is defined as:
--

def formatexception():
   info = sys.exc_info()
    result = "\n<HR>\n<P><B>%s:</B> %s</P>\n" % info[:2]
    if verbose:
        import traceback
        result += '<PRE>' + "\n".join(traceback.format_tb(info[2])) +
'</PRE>\n'
    return result

def printexception(req=sys.stdout):
    req.write(formatexception())

--
The 'verbose' global variable can be turned off and on by sending a request
to the server.



-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.




More information about the Mod_python mailing list