I've got a setup where I am serving simple python pages while using mod_python writer. At some things Let me possess the python function raise a typical apache error - for instance tossing a 500 error if your needed file is missing. How do i throw an apache error from inside a mod_python script?

I'm not a python expert but from this documentation, it appears that that you can do:


In my opinion 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
  raise apache.HTTP_SERVER_RETURN, apache.DONE

raising apache.DONE informs Apache to not create its very own error page.