[mod_python] How to terminate responce?

Graham Dumpleton grahamd at dscpl.com.au
Tue Jun 7 04:35:12 EDT 2005

Clark wrote ..
> Hi,
> With PSP, how to terminate current response?
> I want to check some condition, if it's satisfied, I'll continue, 
> otherwise I'll finish current page. To finish current page, is there
> some function like "req.end()"?
> For example, the PSP script is as follows:
> <%
> if xx != 0:
>    req.end(); 
> ...
> %>
> Actually, there isn't a function "req.end()". I've try to use
> "sys.exit()" instead, but this one will cause a exception. 
> I want to finish the page normally, not a exception.
> Can you give me some hints?


  raise apache.SERVER_RETURN, apache.OK

This might be okay if you are using mod_python.psp direct,
but if you are writing your own handler that is creating an
instance of PSP object and calling its run() method, you will
need to catch the exception, detect that it is just apache.OK
and then finish up your handler as normal. Any other exception
would need to be reraised.


More information about the Mod_python mailing list