#15215: API for simpler (permission or any) checks for generic view classes
---------------------------+------------------------------------------------
Reporter: Ciantic | Owner: nobody
Status: new | Milestone:
Component: Generic views | Version: SVN
Keywords: | Triage Stage: Unreviewed
Has patch: 0 |
---------------------------+------------------------------------------------
The generic class based views are difficult and cumbersome to decorate,
why even trying to reuse the decorator functions? Why not implement simple
functions that would do the checking.
I propose following API for checking the class based views (in this case
just permissions):
{{{
from django.contrib.auth.viewchecks import login_required, has_perms
class ProtectedView(TemplateView):
template_name = 'secret.html'
dispatch_checks = (login_required, has_perms('auth.change_user'),)
}}}
(Notice that I used hypothetical `django.contrib.auth.viewchecks`)
`dispatch_checks` is list of ''functions'' `(request, *args, **kwargs)` ->
`bool` if allowed to dispatch. Thus the `has_perms('auth.change_user')`
should return ''function''.
Above would also allow overriding the `dispatch_checks` tuple in
subclassed views which I think is very important.
I'm working on a simple patch for `django.contrib.auth` and to `View`
class to allow this, these checker functions should be reusable in
decorators.
--
Ticket URL: <http://code.djangoproject.com/ticket/15215>
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 [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-updates?hl=en.