#13879: method_decorator doesn't supports decorators with arguments -------------------------------------+------------------------------------- Reporter: marinho | Owner: nobody Type: New | Status: new feature | Component: Core (Other) Milestone: 1.3 | Severity: Normal Version: 1.2 | Keywords: sprintnov13, Resolution: | decorators Triage Stage: Design | Has patch: 1 decision needed | Needs tests: 0 Needs documentation: 0 | Easy pickings: 0 Patch needs improvement: 1 | -------------------------------------+-------------------------------------
Comment (by lukeplant): @jezdez: My experience with decorators tells me that confusing decorators and decorator factories is always a bad idea, despite the temptation of convenience. If you look at the [http://code.djangoproject.com/browser/django/trunk/django/views/decorators/cache.py#L7 cache_page] decorator, you'll find probably some of the nastiest code in Django, and it was caused by this confusion. You always end up with isinstance checks and horrible little edge cases, and it makes it hard to reason about the code, since it can accept/return fundamentally different types of things. However, in this case, this code: {{{ #!python @method_decorator(permission_required, 'spam.more_eggs', another_arg=True) def method(self, whatever): }}} is no improvement over this code: {{{ #!python @method_decorator(permission_required('spam.more_eggs', another_arg=True)) def method(self, whatever): }}} in terms of the original motivation of this ticket, and it violates TOOWTDI. -- Ticket URL: <https://code.djangoproject.com/ticket/13879#comment:10> Django <https://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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.