On Jul 7, 2006, at 11:21 AM, primco wrote:
> I've seen references to
> m.abort(404, 'Not Found')
>
> this does not work in my 0.9 install
> I've also seen
> return response(code=404)
>
> which does work. However, where is the API documentation for what http
> codes you can specify? I could not find it. Are there any other
> arguements? I'd really like to be able to return a 404 but add a custom
> message as m.abort does, without modifying my error template.
You want paste.httpexceptions, I'll be including an easier way to raise
them, probably in a similar style (an abort), or just making it easier
to raise the exception yourself since most of the time if you get to
the point where you need to return a 500 or 404 response, you want to
stop executing the request.
from paste import httpexceptions
def someaction(self):
raise httpexceptions.HTTPNotFound()
For a full list of them:
http://pythonpaste.org/module-paste.httpexceptions.html
These are caught by the paste exception middleware in your
middleware.py file.
HTH,
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---