Code

Ticket #15840: 15840.patch.diff

File 15840.patch.diff, 1.8 KB (added by portante, 3 years ago)
Line 
1Index: django/views/decorators/http.py
2===================================================================
3--- django/views/decorators/http.py     (revision 16028)
4+++ django/views/decorators/http.py     (working copy)
5@@ -150,7 +150,7 @@
6 
7             return response
8 
9-        return inner
10+        return wraps(func, assigned=available_attrs(func))(inner)
11     return decorator
12 
13 # Shortcut decorators for common cases based on ETag or Last-Modified only
14Index: tests/regressiontests/decorators/tests.py
15===================================================================
16--- tests/regressiontests/decorators/tests.py   (revision 16028)
17+++ tests/regressiontests/decorators/tests.py   (working copy)
18@@ -6,7 +6,7 @@
19 from django.utils.decorators import method_decorator
20 from django.utils.functional import allow_lazy, lazy, memoize
21 from django.utils.unittest import TestCase
22-from django.views.decorators.http import require_http_methods, require_GET, require_POST
23+from django.views.decorators.http import require_http_methods, require_GET, require_POST, condition, etag, last_modified
24 from django.views.decorators.vary import vary_on_headers, vary_on_cookie
25 from django.views.decorators.cache import cache_page, never_cache, cache_control
26 
27@@ -21,6 +21,16 @@
28 fully_decorated = require_GET(fully_decorated)
29 fully_decorated = require_POST(fully_decorated)
30 
31+def last_modified_method(request):
32+    return None
33+
34+def etag_method(request):
35+    return None
36+
37+fully_decorated = condition(etag_func=etag_method, last_modified_func=last_modified_method)(fully_decorated)
38+fully_decorated = etag(etag_method)(fully_decorated)
39+fully_decorated = last_modified(last_modified_method)(fully_decorated)
40+
41 # django.views.decorators.vary
42 fully_decorated = vary_on_headers('Accept-language')(fully_decorated)
43 fully_decorated = vary_on_cookie(fully_decorated)