Esempio n. 1
0
def file_response( filename, data, mimetype = 'application/octet-stream',
                   response = None ):
    """
        sends a file as response.
    """
    if not response:
        response = HttpResponse(mimetype=mimetype)
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    response.write( data )
    try:
        md_data = unicode ( data, errors='ignore')
    except:
        md_data = data
    response['ETag'] = '"%s"' % md5_constructor( md_data ).hexdigest() 
    return response
Esempio n. 2
0
def generate_cache_key(key_prefix, path):
    """Returns a cache key for the header cache."""
    path = md5_constructor(iri_to_uri(path))
    return 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, path.hexdigest())