4 ms·
As opposed to two decorators on the blog module's edit method? I'm not sure a ClassView grants us any advantages for this use. @is_authenticated @is_owner
by thezilch 13y ago
As opposed to two decorators on the blog module's edit method? I'm not sure a ClassView grants us any advantages for this use.
@is_authenticated
@is_owner
def edit(self):
...
- Daishiman 13y agoThe decorator can only add behavior prior to the original function's execution, and many decorators may not necessarily be applied together. CBVs allow a composition of mixins that can include behavior that's substantially more complicated and can deal with any of the methods and members defined for the view. A well-defined base CBV allows you to limit the use of RequestContexts, checks for method types, and special validations. For small projects it may not make a difference; for projects with at least couple dozen views and a bunch of common behavior, they increase readability tremendously. Also, they offer a very good template for defining view behavior. Once you're familiarized with CBV method definitions it's much easier to grok code, as the view flow is much more standardized than for regular function views.