Refs #34, refs #35 - Added documentation about DownloadMixin and BaseDownloadView.

This commit is contained in:
Benoît Bryon 2013-05-28 08:34:33 +02:00
parent 31c0a0f4b9
commit 6c40354f4a
3 changed files with 39 additions and 10 deletions

7
README
View file

@ -25,11 +25,14 @@ Several views are provided to cover frequent use cases:
* ``ObjectDownloadView`` when you have a model with a file field.
* ``StorageDownloadView`` when you manage files in a storage.
* ``PathDownloadView`` when you have an absolute filename on local filesystem.
* ``HTTPDownloadView`` when you have an URL (the resource is proxied).
* ``VirtualDownloadView`` when you the file is generated on the fly.
See :doc:`views` for details.
See `views <https://django-downloadview.readthedocs.org/en/latest/views.html>`_
for details.
Then get increased performances with :doc:`optimizations/index`.
Then `setup optimizations to get increased performances
<https://django-downloadview.readthedocs.org/en/latest/optimizations/index.html>`_.
**********

View file

@ -16,18 +16,19 @@ from django_downloadview.response import DownloadResponse
class DownloadMixin(object):
"""Placeholders and base implementation to create file download views.
The get_file() method is a placeholder, which raises NotImplementedError
in base implementation.
.. note::
The other methods provide an implementation that use the file object
returned by get_file(), supposing the file is hosted on the local
filesystem.
This class does not inherit from
:py:class:`django.views.generic.base.View`.
You may override one or several methods to adapt the implementation to your
use case.
The :py:meth:`get_file` method is a placeholder subclasses must implement.
Base implementation raises ``NotImplementedError``.
Other methods provide a base implementation that use the file wrapper
returned by :py:meth:`get_file`.
"""
#: Response class to be used in render_to_response().
#: Response class, to be used in :py:meth:`render_to_response`.
response_class = DownloadResponse
#: Whether to return the response as attachment or not.

View file

@ -6,6 +6,31 @@ This section contains narrative overview about class-based views provided by
django-downloadview.
*************
DownloadMixin
*************
The :py:class:`django_downloadview.views.DownloadMixin` class is not a view. It
is a base class which you can inherit of to create custom download views.
``DownloadMixin`` is a base of `BaseDownloadView`_, which itself is a base of
all other django_downloadview's builtin views.
****************
BaseDownloadView
****************
The :py:class:`django_downloadview.views.BaseDownloadView` class is a base
class to create download views. It inherits `DownloadMixin`_ and
:py:class:`django.views.generic.base.View`.
The only thing it does is to implement
:py:meth:`get <django_downloadview.views.BaseDownloadView.get>`: it triggers
:py:meth:`DownloadMixin's render_to_response
<django_downloadview.views.DownloadMixin.render_to_response>`.
******************
ObjectDownloadView
******************