From 22e016ff6c18a35a450519b94de63033f83e6b4f Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Thu, 28 Feb 2008 21:24:51 +0000 Subject: gis: Merged revisions 7105-7168 via svnmerge from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7176 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/decorators/cache.py | 9 +++++++-- django/views/decorators/http.py | 7 ++++++- django/views/decorators/vary.py | 9 +++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'django/views/decorators') diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py index b04cc2340b..8b620c1345 100644 --- a/django/views/decorators/cache.py +++ b/django/views/decorators/cache.py @@ -11,6 +11,11 @@ Additionally, all headers from the response's Vary header will be taken into account on caching -- just like the middleware does. """ +try: + from functools import wraps +except ImportError: + from django.utils.functional import wraps # Python 2.3, 2.4 fallback. + from django.utils.decorators import decorator_from_middleware from django.utils.cache import patch_cache_control, add_never_cache_headers from django.middleware.cache import CacheMiddleware @@ -26,7 +31,7 @@ def cache_control(**kwargs): patch_cache_control(response, **kwargs) return response - return _cache_controlled + return wraps(viewfunc)(_cache_controlled) return _cache_controller @@ -39,4 +44,4 @@ def never_cache(view_func): response = view_func(request, *args, **kwargs) add_never_cache_headers(response) return response - return _wrapped_view_func + return wraps(view_func)(_wrapped_view_func) diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py index 9feb8c0d84..dd4f90ea9c 100644 --- a/django/views/decorators/http.py +++ b/django/views/decorators/http.py @@ -2,6 +2,11 @@ Decorators for views based on HTTP headers. """ +try: + from functools import wraps +except ImportError: + from django.utils.functional import wraps # Python 2.3, 2.4 fallback. + from django.utils.decorators import decorator_from_middleware from django.middleware.http import ConditionalGetMiddleware from django.http import HttpResponseNotAllowed @@ -24,7 +29,7 @@ def require_http_methods(request_method_list): if request.method not in request_method_list: return HttpResponseNotAllowed(request_method_list) return func(request, *args, **kwargs) - return inner + return wraps(func)(inner) return decorator require_GET = require_http_methods(["GET"]) diff --git a/django/views/decorators/vary.py b/django/views/decorators/vary.py index 9b49c45cf2..ea1b8d307d 100644 --- a/django/views/decorators/vary.py +++ b/django/views/decorators/vary.py @@ -1,3 +1,8 @@ +try: + from functools import wraps +except ImportError: + from django.utils.functional import wraps # Python 2.3, 2.4 fallback. + from django.utils.cache import patch_vary_headers def vary_on_headers(*headers): @@ -16,7 +21,7 @@ def vary_on_headers(*headers): response = func(*args, **kwargs) patch_vary_headers(response, headers) return response - return inner_func + return wraps(func)(inner_func) return decorator def vary_on_cookie(func): @@ -32,4 +37,4 @@ def vary_on_cookie(func): response = func(*args, **kwargs) patch_vary_headers(response, ('Cookie',)) return response - return inner_func + return wraps(func)(inner_func) -- cgit v1.3