jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
386 stars 57 forks source link

filename, url, size... attributes in DownloadResponse should be lazy #22

Closed benoitbryon closed 11 years ago

benoitbryon commented 11 years ago

In current implementation, views populate the response attributes. But, if some optimizations are configured, the response may be captured and altered. As the file content, response attributes shouldn't be loaded in the view, whenever possible.

benoitbryon commented 11 years ago

Problem partly solved via file wrappers: the view instanciates the file wrapper with just what is needed. Then, if the download response actually streams the file (i.e. if it is not intercepted by some middleware), it uses file wrapper's attribute (which can be lazy).