diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-02-25 06:02:35 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-02-25 06:02:35 +0000 |
| commit | 5ca0b9203b6f852b65f454e1b20bf3d478561b64 (patch) | |
| tree | cacf600c43e187a31fc716b8ff388cf4887c485c /django/contrib/admin/views/decorators.py | |
| parent | 6482f1f8877638493810d2740c56e1b62519c8bd (diff) | |
Fixed #5701 -- Fixed decorators to take the name, attributes, and docstring of the function they decorate by adding a modified version of the `functools.wraps` function from Python 2.5. `wraps` has been altered to work with Django's `curry` function and with Python 2.3, which doesn't allow assignment of a function's `__name__` attribute. This fixes severaly annoyances, such as the online documentation for template filters served by the admin app. This change is backwards incompatible if, for some reason, you were relying on the name of a Django decorator instead of the function it decorates.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7153 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/admin/views/decorators.py')
| -rw-r--r-- | django/contrib/admin/views/decorators.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py index d16fc9ab71..b9fd9ab900 100644 --- a/django/contrib/admin/views/decorators.py +++ b/django/contrib/admin/views/decorators.py @@ -1,3 +1,11 @@ +import base64 +import md5 +import cPickle as pickle +try: + from functools import wraps +except ImportError: + from django.utils.functional import wraps # Python 2.3, 2.4 fallback. + from django import http, template from django.conf import settings from django.contrib.auth.models import User @@ -5,8 +13,6 @@ from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ from django.utils.safestring import mark_safe -import base64, md5 -import cPickle as pickle ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' @@ -104,4 +110,4 @@ def staff_member_required(view_func): else: return _display_login_form(request, ERROR_MESSAGE) - return _checklogin + return wraps(view_func)(_checklogin) |
