diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-04-01 16:18:25 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-04-01 16:18:25 +0000 |
| commit | 6efe30672d51909f63f0187675cb09ceac4f135e (patch) | |
| tree | 38e274a4f3fafecf8070184b10ab0ad1336ae398 /django | |
| parent | 05e3242dc5b9d66507e96c7397c50d4accc92330 (diff) | |
[1.0.X] Fixed #9474: user_passes_test may now be applied multiple times. Backport of r10328 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10329 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/decorators.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py index 1371c62eea..b80aca10a3 100644 --- a/django/contrib/auth/decorators.py +++ b/django/contrib/auth/decorators.py @@ -56,8 +56,19 @@ class _CheckLogin(object): self.test_func = test_func self.login_url = login_url self.redirect_field_name = redirect_field_name - update_wrapper(self, view_func) + # We can't blindly apply update_wrapper because it udpates __dict__ and + # if the view function is already a _CheckLogin object then + # self.test_func and friends will get stomped. However, we also can't + # *not* update the wrapper's dict because then view function attributes + # don't get updated into the wrapper. So we need to split the + # difference: don't let update_wrapper update __dict__, but then update + # the (parts of) __dict__ that we care about ourselves. + update_wrapper(self, view_func, updated=()) + for k in view_func.__dict__: + if k not in self.__dict__: + self.__dict__[k] = view_func.__dict__[k] + def __get__(self, obj, cls=None): view_func = self.view_func.__get__(obj, cls) return _CheckLogin(view_func, self.test_func, self.login_url, self.redirect_field_name) |
