Allura/allura/lib/utils.py
def serve_file(fp, filename, content_type, last_modified=None,
        cache_expires=None, size=None, embed=True, etag=None):
    '''Sets the response headers and serves as a wsgi iter'''
    if not etag and filename and last_modified:
        etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
    if etag:
        etag_cache(etag)
    pylons.response.headers['Content-Type'] = ''
    pylons.response.content_type = content_type.encode('utf-8')
    pylons.response.cache_expires = cache_expires or asint(
        tg.config.get('files_expires_header_secs', 60 * 60))
    pylons.response.last_modified = last_modified
    if size:
        pylons.response.content_length = size
    if 'Pragma' in pylons.response.headers:
        del pylons.response.headers['Pragma']
    if 'Cache-Control' in pylons.response.headers:
        del pylons.response.headers['Cache-Control']
    if not embed:
        pylons.response.headers.add(
            'Content-Disposition',
            'attachment;filename="%s"' % filename.encode('utf-8'))
    # http://code.google.com/p/modwsgi/wiki/FileWrapperExtension
    block_size = 4096
    if 'wsgi.file_wrapper' in tg.request.environ:
        return tg.request.environ['wsgi.file_wrapper'](fp, block_size)
    else:
        return iter(lambda: fp.read(block_size), '')
Sets the response headers and serves as a wsgi iter
Sets the response headers and serves as a wsgi iter
Sets the response headers and serves as a wsgi iter
def serve_file(fp, filename, content_type, last_modified=None,
        cache_expires=None, size=None, embed=True, etag=None):
    if not etag and filename and last_modified:
        etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
    if etag:
        etag_cache(etag)
    pylons.response.headers['Content-Type'] = ''
    pylons.response.content_type = content_type.encode('utf-8')
    pylons.response.cache_expires = cache_expires or asint(
        tg.config.get('files_expires_header_secs', 60 * 60))
    pylons.response.last_modified = last_modified
    if size:
        pylons.response.content_length = size
    if 'Pragma' in pylons.response.headers:
        del pylons.response.headers['Pragma']
    if 'Cache-Control' in pylons.response.headers:
        del pylons.response.headers['Cache-Control']
    if not embed:
        pylons.response.headers.add(
            'Content-Disposition',
            'attachment;filename="%s"' % filename.encode('utf-8'))
    block_size = 4096
    if 'wsgi.file_wrapper' in tg.request.environ:
        return tg.request.environ['wsgi.file_wrapper'](fp, block_size)
    else:
        return iter(lambda: fp.read(block_size), '')
def serve_file ( fp , filename , content_type , last_modified = None , cache_expires = None , size = None , embed = True , etag = None ) : if not etag and filename and last_modified : etag = u'{0}?{1}' . format ( filename , last_modified ) . encode ( 'utf-8' ) if etag : etag_cache ( etag ) pylons . response . headers [ 'Content-Type' ] = '' pylons . response . content_type = content_type . encode ( 'utf-8' ) pylons . response . cache_expires = cache_expires or asint ( tg . config . get ( 'files_expires_header_secs' , 60 * 60 ) ) pylons . response . last_modified = last_modified if size : pylons . response . content_length = size if 'Pragma' in pylons . response . headers : del pylons . response . headers [ 'Pragma' ] if 'Cache-Control' in pylons . response . headers : del pylons . response . headers [ 'Cache-Control' ] if not embed : pylons . response . headers . add ( 'Content-Disposition' , 'attachment;filename="%s"' % filename . encode ( 'utf-8' ) ) block_size = 4096 if 'wsgi.file_wrapper' in tg . request . environ : return tg . request . environ [ 'wsgi.file_wrapper' ] ( fp , block_size ) else : return iter ( lambda : fp . read ( block_size ) , '' )
Sets the response headers and serves as a wsgi iter
Sets the response headers and serves as a wsgi iter
'''Sets the response headers and serves as a wsgi iter''' # http://code.google.com/p/modwsgi/wiki/FileWrapperExtension
fp
filename
content_type
last_modified
cache_expires
size
embed
etag