On Mon, Jul 27, 2009 at 3:47 PM, Benjamin Wohlwend<[email protected]> wrote:
> On Mon, Jul 27, 2009 at 3:27 PM, Anton Bessonov <[email protected]>
> wrote:
>>
>> class Http403(Exception):
>>    pass
>>
>
> It isn't quite that easy. Django special-cases Http404 (see
> django/core/handlers/base.py:112). Simply raising a self-made Http403 will
> result in a HTTP 500 error.

You could write an Exception middleware that takes care of processing
your "special" exception. Bu anyway, note that you are willing is to
give "response" so the right thing to do would be returning a response
object: "from django.http import HttpResponseForbidden" and "return
HttpResponseForbidden()". The exception is Http404 as in that case
there's no one to provide a response! (to say it somehow).

Keep in mind that depending on how you do things you could get
unexpected behaviours with TransactionMiddleware and maybe other
things.

Regards,
Marc

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to