mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
A bunch of improvements for conditional HTTP processing.
Fixed some typos in the code (fixed #10586). Added more tests. Made the tests compatible with Python 2.3. Improved the documentation by putting the good news and common use-case right up front. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10134 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2fb7f5ea2b
commit
e5a8d9e810
5 changed files with 167 additions and 65 deletions
|
@ -1,17 +1,26 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
from django.views.decorators.http import condition
|
||||
from django.views.decorators.http import condition, etag, last_modified
|
||||
from django.http import HttpResponse
|
||||
|
||||
from models import FULL_RESPONSE, LAST_MODIFIED, ETAG
|
||||
|
||||
@condition(lambda r: ETAG, lambda r: LAST_MODIFIED)
|
||||
def index(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
index = condition(lambda r: ETAG, lambda r: LAST_MODIFIED)(index)
|
||||
|
||||
@condition(last_modified_func=lambda r: LAST_MODIFIED)
|
||||
def last_modified(request):
|
||||
def last_modified_view1(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
last_modified_view1 = condition(last_modified_func=lambda r: LAST_MODIFIED)(last_modified_view1)
|
||||
|
||||
@condition(etag_func=lambda r: ETAG)
|
||||
def etag(request):
|
||||
def last_modified_view2(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
last_modified_view2 = last_modified(lambda r: LAST_MODIFIED)(last_modified_view2)
|
||||
|
||||
def etag_view1(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
etag_view1 = condition(etag_func=lambda r: ETAG)(etag_view1)
|
||||
|
||||
def etag_view2(request):
|
||||
return HttpResponse(FULL_RESPONSE)
|
||||
etag_view2 = etag(lambda r: ETAG)(etag_view2)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue