Django

Code

Changeset 175

Show
Ignore:
Timestamp:
07/18/05 12:23:04 (3 years ago)
Author:
adrian
Message:

Moved django.views.decorators.cache.compress_string into django.utils.text

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/text.py

    r3 r175  
    107107         'y': '9', 'x': '9'}.get(m.group(0).lower()) 
    108108    return letters.sub(char2number, phone) 
     109 
     110# From http://www.xhaus.com/alan/python/httpcomp.html#gzip 
     111# Used with permission. 
     112def compress_string(s): 
     113    import cStringIO, gzip 
     114    zbuf = cStringIO.StringIO() 
     115    zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf) 
     116    zfile.write(s) 
     117    zfile.close() 
     118    return zbuf.getvalue() 
  • django/trunk/django/views/decorators/cache.py

    r3 r175  
    11from django.core.cache import cache 
    22from django.utils.httpwrappers import HttpResponseNotModified 
    3 import cStringIO, datetime, gzip, md5 
    4  
    5 # From http://www.xhaus.com/alan/python/httpcomp.html#gzip 
    6 # Used with permission. 
    7 def compress_string(s): 
    8     zbuf = cStringIO.StringIO() 
    9     zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf) 
    10     zfile.write(s) 
    11     zfile.close() 
    12     return zbuf.getvalue() 
     3from django.utils.text import compress_string 
     4import datetime, md5 
    135 
    146def cache_page(view_func, cache_timeout, key_prefix=''): 
     
    2214    use cache; otherwise the cache for one site would affect the other. A good 
    2315    example of key_prefix is to use sites.get_current().domain, because that's 
    24     unique across all CMS instances on a particular server. 
     16    unique across all Django instances on a particular server. 
    2517    """ 
    2618    def _check_cache(request, *args, **kwargs):