tickets: 7894
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7894 | 2008-07-22 14:45:31 | 2009-02-25 19:51:44 | 2022-03-06 03:40:51.307365 | Design decision needed | closed | Core (Other) | dev | duplicate | Support handler optimisations for file downloads | 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) }}} | nobody | graham.carlyle@maplecroft.com | 0 | 1 | 0 | 0 | 0 | 0 |