I have a setup where I'm serving simple python pages using the mod_python publisher. At some points I'd like to have the python function raise a standard apache error - for example throwing a 500 error if a required file is missing. How can I throw an apache error from within a mod_python script?
+1
A:
I am not a python expert but from this documentation, it would appear that you can do:
raise apache.SERVER_RETURN, apache.HTTP_INTERNAL_SERVER_ERROR
Josh
2010-04-20 15:19:46
A:
I believe it's:
def my_action(req):
# all the status code constants are defined in the apache module
req.status = apache.HTTP_INTERNAL_SERVER_ERROR
req.content_type = some_mime_type
req.write(content)
raise apache.HTTP_SERVER_RETURN, apache.DONE
raising apache.DONE tells Apache not to write out its own error page.
Matthew Flaschen
2010-04-20 15:39:50