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
This has come up before (I think several times). I used to be in the exceptions-for-any-error-response camp, but now I actually wonder why Http404 needs to be a special case at all. I think I'd be perfectly happy just returning HttpResponseNotFound. I eventually came to realize that the need to raise exceptions to trigger responses may indicate suboptimal layering in my view functions. It probably means that some helper function is confused and thinks that it is a view function (in fact, the code in the helper function probably got ripped out of a view function). Keeping HTTP-related logic in the view function itself alleviates the need for a Http403 exception. -Forest -- Forest Bond http://www.alittletooquiet.net http://www.pytagsfs.org
signature.asc
Description: Digital signature
