Ticket #6181: document-view-decorators2.diff
File document-view-decorators2.diff, 3.8 KB (added by , 14 years ago) |
---|
-
docs/index.txt
diff --git a/docs/index.txt b/docs/index.txt index 632adc8..0cf066e 100644
a b The view layer 91 91 * **The basics:** 92 92 :doc:`URLconfs <topics/http/urls>` | 93 93 :doc:`View functions <topics/http/views>` | 94 :doc:`Shortcuts <topics/http/shortcuts>` 94 :doc:`Shortcuts <topics/http/shortcuts>` | 95 :doc:`Decorators <topics/http/decorators>` 95 96 96 97 * **Reference:** 97 98 :doc:`Request/response objects <ref/request-response>` | -
docs/ref/middleware.txt
diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt index b3ddb23..9fff219 100644
a b compress content bodies less than 200 bytes long, when the response code is 103 103 something other than 200, JavaScript files (for IE compatibility), or 104 104 responses that have the ``Content-Encoding`` header already specified. 105 105 106 GZip compression can be applied to individual views using the 107 :func:`~django.views.decorators.http.gzip_page()` decorator. 108 106 109 Conditional GET middleware 107 110 -------------------------- 108 111 -
docs/topics/cache.txt
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index dd3fd78..4c35cd4 100644
a b exist to instruct upstream caches to differ their cache contents depending on 964 964 designated variables, and to tell caching mechanisms not to cache particular 965 965 pages. We'll look at some of these headers in the sections that follow. 966 966 967 .. _using-vary-headers: 968 967 969 Using Vary headers 968 970 ================== 969 971 -
new file docs/topics/http/decorators.txt
diff --git a/docs/topics/http/decorators.txt b/docs/topics/http/decorators.txt new file mode 100644 index 0000000..500769c
- + 1 =============== 2 View Decorators 3 =============== 4 5 .. currentmodule:: django.views.decorators.http 6 7 Django provides several decorators that can be applied to views to support 8 various HTTP features. 9 10 Allowed HTTP Methods 11 ==================== 12 13 .. function:: require_http_methods(request_method_list) 14 15 This decorator is used to make a view only accept particular request methods. 16 Usage:: 17 18 @require_http_methods(["GET", "POST"]) 19 def my_view(request): 20 # I can assume now that only GET or POST requests make it this far 21 # ... 22 23 Note that request methods should be in uppercase. 24 25 .. function:: require_GET() 26 27 Decorator to require that a view only accept the GET method. 28 29 .. function:: require_POST() 30 31 Decorator to require that a view only accept the POST method. 32 33 Conditional view processing 34 =========================== 35 36 .. function:: condition(etag_func=None, last_modified_func=None) 37 38 .. function:: etag(etag_func) 39 40 .. function:: last_modified(last_modified_func) 41 42 These decorators can be used to generate ``ETag`` and ``Last-Modified`` 43 headers; see 44 :doc:`conditional view processing </topics/conditional-view-processing>`. 45 46 .. currentmodule:: django.views.decorators.http 47 48 GZip Compression 49 ================ 50 51 .. function:: gzip_page() 52 53 This decorator compresses content if the browser allows gzip compression. 54 It sets the ``Vary`` header accordingly, so that caches will base their 55 storage on the ``Accept-Encoding`` header. 56 57 .. currentmodule:: django.views.decorators.vary 58 59 Vary Headers 60 ============ 61 62 The ``Vary`` header defines which request headers a cache mechanism should take 63 into account when building its cache key. 64 65 .. function:: vary_on_cookie(func) 66 67 .. function:: vary_on_headers(*headers) 68 69 See :ref:`using vary headers <using-vary-headers>`. -
docs/topics/http/index.txt
diff --git a/docs/topics/http/index.txt b/docs/topics/http/index.txt index 5ef776d..0bcb3a2 100644
a b Information on handling HTTP requests in Django: 8 8 9 9 urls 10 10 views 11 decorators 11 12 file-uploads 12 13 shortcuts 13 14 generic-views