On 16 September 2011 09:17, Jonas H. <[email protected]> wrote: > On 09/15/2011 11:27 PM, Donald Stufft wrote: >> >> tl;dr; Using Mixins to add in functionality to a CBV makes way more sense >> then >> using a decorator which is essentially going to be doing the same thing as >> a >> mixing would, it just makes finding what is going on harder, makes >> customizing >> the decorator harder and/or uglier, and goes against the way functionality >> is >> currently added to a CBV. > > That sounds a lot better to me. >
Surprisingly, I agree. Using decorators to *add functionality* is a bad idea. But `login_required` or `csrf_exempt` are not strictly functionalities. They're preconditions. They act exactly like any piece of middleware, but instead of applying them globally to all view, you can do it per-view. (My view_decorator intentionally uses as_view() instead of dispatch(), so that the decorators are called *before*, any view login is called). If you think about it this way, applying decorators to CBV makes a lot of sense. -- Łukasz Rekucki -- You received this message because you are subscribed to the Google Groups "Django developers" 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-developers?hl=en.
