Moved django.views.decorators.cache.compress_string into django.utils.text
git-svn-id: http://code.djangoproject.com/svn/django/trunk@175 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b68c478aa5
commit
912253371d
|
@ -106,3 +106,13 @@ def phone2numeric(phone):
|
||||||
's': '7', 'r': '7', 'u': '8', 't': '8', 'w': '9', 'v': '8',
|
's': '7', 'r': '7', 'u': '8', 't': '8', 'w': '9', 'v': '8',
|
||||||
'y': '9', 'x': '9'}.get(m.group(0).lower())
|
'y': '9', 'x': '9'}.get(m.group(0).lower())
|
||||||
return letters.sub(char2number, phone)
|
return letters.sub(char2number, phone)
|
||||||
|
|
||||||
|
# From http://www.xhaus.com/alan/python/httpcomp.html#gzip
|
||||||
|
# Used with permission.
|
||||||
|
def compress_string(s):
|
||||||
|
import cStringIO, gzip
|
||||||
|
zbuf = cStringIO.StringIO()
|
||||||
|
zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
|
||||||
|
zfile.write(s)
|
||||||
|
zfile.close()
|
||||||
|
return zbuf.getvalue()
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.utils.httpwrappers import HttpResponseNotModified
|
from django.utils.httpwrappers import HttpResponseNotModified
|
||||||
import cStringIO, datetime, gzip, md5
|
from django.utils.text import compress_string
|
||||||
|
import datetime, md5
|
||||||
# From http://www.xhaus.com/alan/python/httpcomp.html#gzip
|
|
||||||
# Used with permission.
|
|
||||||
def compress_string(s):
|
|
||||||
zbuf = cStringIO.StringIO()
|
|
||||||
zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
|
|
||||||
zfile.write(s)
|
|
||||||
zfile.close()
|
|
||||||
return zbuf.getvalue()
|
|
||||||
|
|
||||||
def cache_page(view_func, cache_timeout, key_prefix=''):
|
def cache_page(view_func, cache_timeout, key_prefix=''):
|
||||||
"""
|
"""
|
||||||
|
@ -21,7 +13,7 @@ def cache_page(view_func, cache_timeout, key_prefix=''):
|
||||||
variable. Use key_prefix if your Django setup has multiple sites that
|
variable. Use key_prefix if your Django setup has multiple sites that
|
||||||
use cache; otherwise the cache for one site would affect the other. A good
|
use cache; otherwise the cache for one site would affect the other. A good
|
||||||
example of key_prefix is to use sites.get_current().domain, because that's
|
example of key_prefix is to use sites.get_current().domain, because that's
|
||||||
unique across all CMS instances on a particular server.
|
unique across all Django instances on a particular server.
|
||||||
"""
|
"""
|
||||||
def _check_cache(request, *args, **kwargs):
|
def _check_cache(request, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue