On 12/18/2010 10:30 AM, Łukasz Rekucki wrote:
On 18 December 2010 03:43, suckerfish<yip...@gmail.com> wrote:
Hi guys
I've added a decorator to *each* def in views.py to require
authentication. Is there a simpler way that allows me to apply
authentication automatically to every def in the file?
Depends on your code editor ?
That's not very DRY, is it :-) Try class-based views (Django 1.3/trunk).
If you can't/don't want to use Django 1.3, you could do some automagic
"decorating" at the end of the file:
for view in ['view1, 'view2', ...]:
eval('{0} = your_decorator({0})'.format(view)')
Of couse you should prefer the first way.
Hope this helps :-)
Jonas
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.