Forest Bond wrote:
> But your model code shouldn't have HTTP-related bits buried in it. That's a
> layering violation. That code should raise a more generic exception that your
> view code converts to an HTTP response.
Yes, this is may be more correct way. But having one exception without a
co
elieve that making a special
> exception and converting it into an HttpResponseForbidden in a
> middleware is a good way to do this in current Django code. But I can
> really see the value of making it a part of Django even if just for the
> sake of consistency with Http404. BTW other HTTP e
urrent Django code. But I can
really see the value of making it a part of Django even if just for the
sake of consistency with Http404. BTW other HTTP errors in my practice
don't work by this pattern so I don't propose making an exception for
everything >= 400.
--~--~-~--~--
Hi,
On Mon, Jul 27, 2009 at 03:10:59PM +0200, Jonas Obrist wrote:
> I don't quite understand why I can raise a Http404 but not for example a
> Http403.
>
> I think one should be able to either raise all Http error codes (4xx,
> 5xx) or none. And I'd prefer being able to raise them as Exceptions
On Mon, Jul 27, 2009 at 3:47 PM, Benjamin Wohlwend wrote:
> On Mon, Jul 27, 2009 at 3:27 PM, Anton Bessonov
> 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 Http40
Using e.x. raise Http404 isn't clean solution. Is a very ugly shortcut.
So you can return always a 404-view. All other unhandled errors given
500 - is general server error for _unhandled_ exception. Maybe I was
wrong, but using exceptions is not pretty way.
Jonas Obrist schrieb:
> It probably
It probably wouldn't be impossible to do it yourself and I'm well aware
of the HttpResponseForbidden, but to me it doesn't makes sense that one
error is considered an exception in django and the other ones responses.
I'd like to see a unified way to handle this in Django and not just in
my app
Hi,
On Mon, Jul 27, 2009 at 3:27 PM, Anton Bessonov wrote:
>
> http/__init__.py describe Http404 Exception as:
>
> class Http404(Exception):
>pass
>
> You can make own Exception:
>
> class Http403(Exception):
>pass
>
>
It isn't quite that easy. Django special-cases Http404 (see
django/cor
http/__init__.py describe Http404 Exception as:
class Http404(Exception):
pass
You can make own Exception:
class Http403(Exception):
pass
For 403 Response do you have HttpResponseForbidden in other Hand.
Jonas Obrist schrieb:
> I don't quite understand why I can raise a Http404 but no
I don't quite understand why I can raise a Http404 but not for example a
Http403.
I think one should be able to either raise all Http error codes (4xx,
5xx) or none. And I'd prefer being able to raise them as Exceptions
--~--~-~--~~~---~--~~
You received this me
10 matches
Mail list logo