﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9474	user_passes_test decorator cannot be applied twice	Manuel Saelices	Manuel Saelices	"Look at this code:
{{{
#!python
from django.contrib.auth.decorators import user_passes_test

def decorator1(view_func=None):
    def _test_func(user, *args, **kwargs):
        print 'decorator1 test func'
        return True
    return user_passes_test(_test_func)(view_func)

def decorator2(view_func=None):
    def _test_func(user, *args, **kwargs):
        print 'decorator2 test func'
        return True
    return user_passes_test(_test_func)(view_func)

@decorator1
@decorator2
def book_list(request):
    books = Book.objects.all()
    return render_to_response('books/book_list.html', {'books': books})
}}}

If you call {{{book_list}}} view, decorated both with {{{decorator1}}} and {{{decorator2}}}, only {{{decorator2}}} will be applied. For this exampled, only will appear in django console ''decorator2 test func''.

This is for the use of {{{update_wrapper}}} function in {{{_CheckLogin}}} class in {{{django/contrib/auth/decorators.py}}}, that override {{{__dict__}}} of function wrapped. Second decorator definition override {{{self.view_func}}} attribute of the other decorator (both are {{{_CheckLogin}}} objects).

Look at the patch for more details."		closed	contrib.auth	1.0		fixed			Accepted	1	0	0	0	0	0
