#4617: permission_required decorator behaviour is odd -----------------------------------------+---------------------------------- Reporter: cbr...@redback.com | Owner: ctrochalakis Status: assigned | Milestone: Component: Contrib apps | Version: SVN Resolution: | Keywords: easy-pickings Stage: Accepted | Has_patch: 1 Needs_docs: 1 | Needs_tests: 0 Needs_better_patch: 1 | -----------------------------------------+---------------------------------- Comment (by alex_dev):
Please consider another approach: {{{ from django.core.exceptions import PermissionDenied def permission_required(perm, login_url=None): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. """ def check_perms(user): if user.is_anonymous(): return False if user.has_perm(perm): return True raise PermissionDenied return user_passes_test(check_perms, login_url=login_url) }}} This one doesn't change semantics of 'user_passes_test'. It depends on #9847 for handling PermissionDenied exception. -- Ticket URL: <http://code.djangoproject.com/ticket/4617#comment:20> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.