Ticket #5176: 0002_generate_cache_key.diff
File 0002_generate_cache_key.diff, 3.6 KB (added by , 16 years ago) |
---|
-
django/utils/cache.py
23 23 set 24 24 except NameError: 25 25 from sets import Set as set # Python 2.3 fallback 26 from Cookie import SimpleCookie 26 27 27 28 from django.conf import settings 28 29 from django.core.cache import cache … … 141 142 ctx = md5_constructor() 142 143 for header in headerlist: 143 144 value = request.META.get(header, None) 145 if isinstance(value, SimpleCookie): 146 value = value.output() 147 144 148 if value is not None: 145 149 ctx.update(value) 146 150 return 'views.decorators.cache.cache_page.%s.%s.%s' % ( -
tests/regressiontests/test_client_regress/views.py
46 46 47 47 def request_methods_view(request): 48 48 "A view that responds with the request method" 49 return HttpResponse('request method: %s' % request.method) 50 No newline at end of file 49 return HttpResponse('request method: %s' % request.method) 50 51 def set_cookie_view(request): 52 "A view that sets a cookie." 53 response = HttpResponse('set cookie') 54 response.set_cookie('test_cookie', 'test_value') 55 56 return response -
tests/regressiontests/test_client_regress/models.py
2 2 Regression tests for the Test Client, especially the customized assertions. 3 3 """ 4 4 import os 5 from Cookie import SimpleCookie 6 5 7 from django.conf import settings 6 7 8 from django.test import Client, TestCase 8 9 from django.core.urlresolvers import reverse 9 10 from django.core.exceptions import SuspiciousOperation … … 261 262 # default client. 262 263 self.assertRedirects(response, "http://testserver/test_client_regress/get_view/") 263 264 265 class CookieTests(TestCase): 266 267 def test_cookies(self): 268 "Check that cookies work in the test client, see ticket #5176." 269 270 c = Client() 271 response = c.get('/test_client_regress/set_cookie/') 272 273 self.assert_(isinstance(response.cookies, SimpleCookie)) 274 self.assert_(response.cookies.output().find('Set-Cookie: test_cookie=test_value; Path=/') >= 0) 275 264 276 class URLEscapingTests(TestCase): 265 277 def test_simple_argument_get(self): 266 278 "Get a view that has a simple string argument" -
tests/regressiontests/test_client_regress/urls.py
10 10 (r'^set_session/$', views.set_session_view), 11 11 (r'^check_session/$', views.check_session_view), 12 12 (r'^request_methods/$', views.request_methods_view), 13 (r'^set_cookie/$', views.set_cookie_view) 13 14 ) -
AUTHORS
239 239 Lau Bech Lauritzen 240 240 Rune Rønde Laursen <runerl@skjoldhoej.dk> 241 241 Eugene Lazutkin <http://lazutkin.com/blog/> 242 lcordier@point45.com242 Louis Cordier <lcordier@gmail.com> 243 243 Jeong-Min Lee <falsetru@gmail.com> 244 244 Jannis Leidel <jl@websushi.org> 245 245 Christopher Lenz <http://www.cmlenz.net/>