Ticket #15637: add-require-safe-http-decorator.patch
File add-require-safe-http-decorator.patch, 2.3 KB (added by , 14 years ago) |
---|
-
docs/topics/http/decorators.txt
36 36 37 37 Decorator to require that a view only accept the POST method. 38 38 39 .. function:: require_safe() 40 41 Decorator to require that a view only accept the GET and HEAD methods. It is similar to require_GET, but does not break software relying on HEAD requests, like link checkers. 42 43 39 44 Conditional view processing 40 45 =========================== 41 46 -
tests/regressiontests/decorators/tests.py
10 10 from django.utils.decorators import method_decorator 11 11 from django.utils.functional import allow_lazy, lazy, memoize 12 12 from django.utils.unittest import TestCase 13 from django.views.decorators.http import require_http_methods, require_GET, require_POST 13 from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe 14 14 from django.views.decorators.vary import vary_on_headers, vary_on_cookie 15 15 from django.views.decorators.cache import cache_page, never_cache, cache_control 16 16 … … 24 24 fully_decorated = require_http_methods(["GET"])(fully_decorated) 25 25 fully_decorated = require_GET(fully_decorated) 26 26 fully_decorated = require_POST(fully_decorated) 27 fully_decorated = require_safe(fully_decorated) 27 28 28 29 # django.views.decorators.vary 29 30 fully_decorated = vary_on_headers('Accept-language')(fully_decorated) -
django/views/decorators/http.py
52 52 require_POST = require_http_methods(["POST"]) 53 53 require_POST.__doc__ = "Decorator to require that a view only accept the POST method." 54 54 55 require_safe = require_http_methods(["GET", "HEAD"]) 56 require_safe.__doc__ = "Decorator to require that a view only accept the GET and HEAD methods." 57 55 58 def condition(etag_func=None, last_modified_func=None): 56 59 """ 57 60 Decorator to support conditional retrieval (or change) for a view