﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7894	Support handler optimisations for file downloads	graham.carlyle@…	nobody	"Sometimes a django app wants to return a file in a response. You can currently do this by returning the data or an iterator for the data in the content of an HttpResponse. However WSGI provides an optional mechanism for higher performance file transmission...

http://www.python.org/dev/peps/pep-0333/#optional-platform-specific-file-handling

...and I imagine mod_python is capable of a similar speed up.

In order to flag to the handler that the response is suitable for this speedup I suggest a new HttpResponseFileWrapper object that wraps a file like object. This response falls back to providing its content via an iterator that reads in block_size (a extra optional parameter) bytes at a time. The speedup mechanism can also use the block_size as a suggestion for reading data from the filelike object.

So for example...

{{{
from django.http import HttpResponseFileWrapper

def view(request):
    return HttpResponseFileWrapper(open('foo.pdf'), block_size=8192)
}}}
"		closed	Core (Other)	dev		duplicate		django-ticket-7894@… piranha@…	Design decision needed	1	0	0	0	0	0
