On Jun 8, 2013, at 12:48 PM, Hanne Moa <hanne....@gmail.com> wrote: > On 3 June 2013 18:09, <gavinw...@gmail.com> wrote: > # `DecoratorMixin` > > `DecoratorMixin` is a class factory that converts any view decorator into a > class-based view mixin. > > Using it is easy and intuitive: > > LoginRequiredMixin = DecoratorMixin(login_required) > > Now this, this feels pythonic. Bravo! I'm so doing this in future > projects... (Though, class factories are spelled lowercase_with_underscores, > no? At least in Django. For instance formset_factory().) > > I've had a look at various LoginRequiredMixins out there (everybody makes > their own it seems, including me). It is quite common that it doesn't cover > all the things that login_required covers (like supporting the new way of > doing users in 1.5) so in the case of LoginRequiredMixin, I think the safest > solution is to include a mixin in core anyway. > > > HM > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > >
Part of the reasoning of my original Change to make decorators classes was that it enabled much easier customization of them. Currently you basically either hope there was an option for doing what you wanted, or you copy/paste the entire thing and modify it. Using a class lets you override it. ----------------- Donald Stufft PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
signature.asc
Description: Message signed with OpenPGP using GPGMail