> Http403 would be nice too. raise django.core.exceptions.PermissionDenied
Best regards, paluh 2010/6/28 Michael Cetrulo <mail2sa...@gmail.com>: > Http403 would be nice too. > > http://chronosbox.org/blog/manipulando-erros-http-403-permissao-negada-no-django?lang=en > http://theglenbot.com/creating-a-custom-http403-exception-in-django > http://groups.google.com/group/django-users/browse_thread/thread/8d3dda89858ff2ee > > On Mon, Jun 28, 2010 at 12:36 PM, Gabriel Hurley <gab...@gmail.com> wrote: >> >> Http301 doesn't seem entirely correct to me, however I have found use >> for an Http302/HttpLoginRedirect exception that can be raised from >> anywhere to handle unauthorized users. >> >> If your authorization process is handled somewhere other than directly >> in a view or decorator (like in a manager that checks custom >> permissions) it can be a nuisance to constantly be checking the >> returned value to make sure it's not a redirect. Raising an exception >> there and catching it with a middleware works nicely. >> >> I'm not saying that it needs to be in core, but it's been extremely >> helpful for me and might be useful for others. >> >> All the best, >> >> - Gabriel >> >> On Jun 28, 8:14 am, Patryk Zawadzki <pat...@pld-linux.org> wrote: >> > On Mon, Jun 28, 2010 at 12:07 PM, kernel1983 <kernel1...@gmail.com> >> > wrote: >> > > There is exception Http404 in the system. >> > >> > > During django programming, we often need to do some data valid: >> > >> > > def A(request): >> > > valid() >> > > return render_to_response(...) >> > >> > > def B(request): >> > > valid() >> > > return render_to_response(...) >> > > ... >> > >> > > def valid(): >> > > throw Http301(url) >> > >> > from django.shortcuts import redirect >> > >> > def valid(method): >> > def decorated(request, *args, **kwargs): >> > if not 'Tim' in request.user.called_by_some_people(): >> > return redirect('some-view', ...) >> > return method(request, *args, **kwargs) >> > return decorated >> > >> > @valid >> > def A(request): >> > return render_to_response(...) >> > >> > @valid >> > def B(request): >> > return render_to_response(...) >> > >> > print 'There you go.' >> > >> > -- >> > Patryk Zawadzki >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers" group. >> To post to this group, send email to django-develop...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-developers+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-developers?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to django-develop...@googlegroups.com. > To unsubscribe from this group, send email to > django-developers+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.