summaryrefslogtreecommitdiff
path: root/tests/regressiontests/conditional_processing/views.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-03-22 07:58:29 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-03-22 07:58:29 +0000
commitb203db6ec850fee9ad8f2e2c8873be986325572b (patch)
tree349736a64d97e83f5817d79e7e12ad84973cdc0a /tests/regressiontests/conditional_processing/views.py
parent5ac154e06568b9815e85b32f144ab4ee10190a61 (diff)
Fixed #5791 -- Added early-bailout support for views (ETags and Last-modified).
This provides support for views that can have their ETag and/or Last-modified values computed much more quickly than the view itself. Supports all HTTP verbs (not just GET). Documentation and tests need a little more fleshing out (I'm not happy with the documentation at the moment, since it's a bit backwards), but the functionality is correct. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10114 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/conditional_processing/views.py')
-rw-r--r--tests/regressiontests/conditional_processing/views.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/regressiontests/conditional_processing/views.py b/tests/regressiontests/conditional_processing/views.py
new file mode 100644
index 0000000000..c88236e21b
--- /dev/null
+++ b/tests/regressiontests/conditional_processing/views.py
@@ -0,0 +1,17 @@
+# -*- coding:utf-8 -*-
+from django.views.decorators.http import condition
+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)
+
+@condition(last_modified_func=lambda r: LAST_MODIFIED)
+def last_modified(request):
+ return HttpResponse(FULL_RESPONSE)
+
+@condition(etag_func=lambda r: ETAG)
+def etag(request):
+ return HttpResponse(FULL_RESPONSE)