[mod_python] Setting HTTP response status line

Mike Looijmans nlv11281 at natlab.research.philips.com
Tue May 8 02:11:09 EDT 2007


Roger Binns wrote:
> Yup, I have to revisit how to deal with returning error information in
> machine and human readable forms.  Short of the status line, I guess
> headers are going to be the best for machine readable.

When testing, I just return a 500 page, with an Exception header and a format of text/plain with the 
traceback and stuff. The handler code just throws that text in a new exception and that makes it end 
up into the test logs (unless the call was supposed to fail - bad weather testing is good for the soul).

> Hmmm, I wonder if I could pickle an exception and traceback, base64
> encode it and return in a header?  Kidding :-)

Why in the header? You can use the body as well, so you won't need the encoding at all. It can be 
done, but you must have all the modules that are touched in the traceback at the client side.

On second guess, it won't work because the objects the stack trace refers to can probably not be 
pickled anyway (callables, instances of weird classes, ...). It's safer to convert to text first 
using the traceback module.

--
Mike Looijmans
Philips Natlab / Topic Automation





More information about the Mod_python mailing list