1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

Made several grammar fixes to cache documentation from [1020]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1030 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2005-10-31 03:14:57 +00:00
parent fb55717a09
commit cbe2426369
2 changed files with 57 additions and 33 deletions

View File

@@ -22,19 +22,19 @@ from django.conf import settings
from django.core.cache import cache
cc_delim_re = re.compile(r'\s*,\s*')
def patch_cache_control(response, **kwargs):
"""
This function patches the Cache-Control header by adding all
keyword arguments to it. The transformation is as follows:
- all keyword parameter names are turned to lowercase and
all _ will be translated to -
- if the value of a parameter is True (exatly True, not just a
true value), only the parameter name is added to the header
- all other parameters are added with their value, after applying
str to it.
* All keyword parameter names are turned to lowercase, and underscores
are converted to hyphens.
* If the value of a parameter is True (exactly True, not just a
true value), only the parameter name is added to the header.
* All other parameters are added with their value, after applying
str() to it.
"""
def dictitem(s):
t = s.split('=',1)
if len(t) > 1:
@@ -49,9 +49,7 @@ def patch_cache_control(response, **kwargs):
return t[0] + '=' + str(t[1])
if response.has_header('Cache-Control'):
print response['Cache-Control']
cc = cc_delim_re.split(response['Cache-Control'])
print cc
cc = dict([dictitem(el) for el in cc])
else:
cc = {}