[Python-modules-commits] [django-downloadview] 01/02: Imported Upstream version 1.8

Michael Fladischer fladi at moszumanska.debian.org
Thu Sep 3 15:52:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository django-downloadview.

commit fa40a747eb12618a976ff1aa286a4648ea1dc389
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Thu Sep 3 15:46:11 2015 +0200

    Imported Upstream version 1.8
---
 AUTHORS                                           |  15 ++
 CHANGELOG                                         | 199 +++++++++++++++++
 CONTRIBUTING.rst                                  |  94 ++++++++
 INSTALL                                           |  88 ++++++++
 LICENSE                                           |  31 +++
 MANIFEST.in                                       |   9 +
 PKG-INFO                                          |  67 ++++++
 README.rst                                        |  50 +++++
 VERSION                                           |   1 +
 django_downloadview.egg-info/PKG-INFO             |  67 ++++++
 django_downloadview.egg-info/SOURCES.txt          |  50 +++++
 django_downloadview.egg-info/dependency_links.txt |   1 +
 django_downloadview.egg-info/not-zip-safe         |   1 +
 django_downloadview.egg-info/pbr.json             |   1 +
 django_downloadview.egg-info/requires.txt         |   7 +
 django_downloadview.egg-info/top_level.txt        |   1 +
 django_downloadview/__init__.py                   |  12 +
 django_downloadview/apache/__init__.py            |  13 ++
 django_downloadview/apache/decorators.py          |  16 ++
 django_downloadview/apache/middlewares.py         |  30 +++
 django_downloadview/apache/response.py            |  18 ++
 django_downloadview/apache/tests.py               |  62 ++++++
 django_downloadview/api.py                        |  27 +++
 django_downloadview/decorators.py                 |  32 +++
 django_downloadview/exceptions.py                 |  11 +
 django_downloadview/files.py                      | 258 ++++++++++++++++++++++
 django_downloadview/io.py                         | 142 ++++++++++++
 django_downloadview/lighttpd/__init__.py          |  14 ++
 django_downloadview/lighttpd/decorators.py        |  16 ++
 django_downloadview/lighttpd/middlewares.py       |  30 +++
 django_downloadview/lighttpd/response.py          |  18 ++
 django_downloadview/lighttpd/tests.py             |  28 +++
 django_downloadview/middlewares.py                | 209 ++++++++++++++++++
 django_downloadview/nginx/__init__.py             |  14 ++
 django_downloadview/nginx/decorators.py           |  16 ++
 django_downloadview/nginx/middlewares.py          | 120 ++++++++++
 django_downloadview/nginx/response.py             |  34 +++
 django_downloadview/nginx/settings.py             | 128 +++++++++++
 django_downloadview/nginx/tests.py                | 120 ++++++++++
 django_downloadview/response.py                   | 246 +++++++++++++++++++++
 django_downloadview/shortcuts.py                  |  19 ++
 django_downloadview/test.py                       | 175 +++++++++++++++
 django_downloadview/utils.py                      |  47 ++++
 django_downloadview/views/__init__.py             |  12 +
 django_downloadview/views/base.py                 | 170 ++++++++++++++
 django_downloadview/views/http.py                 |  46 ++++
 django_downloadview/views/object.py               |  98 ++++++++
 django_downloadview/views/path.py                 |  39 ++++
 django_downloadview/views/storage.py              |  29 +++
 django_downloadview/views/virtual.py              |  31 +++
 setup.cfg                                         |   5 +
 setup.py                                          |  96 ++++++++
 52 files changed, 3063 insertions(+)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..d45879e
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,15 @@
+######################
+Authors & contributors
+######################
+
+Maintainer: Benoît Bryon <benoit at marmelune.net>
+
+Original code by `Novapost <http://www.novapost.fr>`_ team:
+
+* Nicolas Tobo <https://github.com/nicolastobo>
+* Lauréline Guérin <https://github.com/zebuline>
+* Gregory Tappero <https://github.com/coulix>
+* Rémy Hubscher <remy.hubscher at novapost.fr>
+* Benoît Bryon <benoit at marmelune.net>
+
+Developers: https://github.com/benoitbryon/django-downloadview/graphs/contributors
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..a5db752
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,199 @@
+Changelog
+=========
+
+This document describes changes between past releases. For information about
+future releases, check `milestones`_ and :doc:`/about/vision`.
+
+
+1.8 (2015-07-20)
+----------------
+
+Bugfixes.
+
+- Bugfix #103 - ``PathDownloadView.get_file()`` makes a single call to
+  ``PathDownloadView.get_file()`` (was doing it twice).
+
+- Bugfix #104 - Pass numeric timestamp to Django's ``was_modified_since()``
+  (was passing a datetime).
+
+
+1.7 (2015-06-13)
+----------------
+
+Bugfixes.
+
+- Bugfix #87 - Filenames with commas are now supported. In download responses,
+  filename is now surrounded by double quotes.
+
+- Bugfix #97 - ``HTTPFile`` proxies bytes as ``BytesIteratorIO`` (was undecoded
+  urllib3 file object). ``StringIteratorIO`` has been split into
+  ``TextIteratorIO`` and ``BytesIteratorIO``. ``StringIteratorIO`` is
+  deprecated but kept for backward compatibility as an alias for
+  ``TextIteratorIO``.
+
+- Bugfix #92 - Run demo using ``make demo runserver`` (was broken).
+
+- Feature #99 - Tox runs project's tests with Python 2.7, 3.3 and 3.4, and with
+  Django 1.5 to 1.8.
+
+- Refactoring #98 - Refreshed development environment: packaging, Tox and
+  Sphinx.
+
+
+1.6 (2014-03-03)
+----------------
+
+Python 3 support, development environment refactoring.
+
+- Feature #46: introduced support for Python>=3.3.
+
+- Feature #80: added documentation about "how to serve a file inline VS how to
+  serve a file as attachment". Improved documentation of views' base options
+  inherited from ``DownloadMixin``.
+
+- Feature #74: the Makefile in project's repository no longer creates a
+  virtualenv. Developers setup the environment as they like, i.e. using
+  virtualenv, virtualenvwrapper or whatever. Tests are run with tox.
+
+
+1.5 (2013-11-29)
+----------------
+
+X-Sendfile support and helpers to migrate for `django-sendfile`.
+
+- Feature #2 - Introduced support of Lighttpd's x-Sendfile.
+
+- Feature #36 - Introduced support of Apache's mod_xsendfile.
+
+- Feature #41 - ``django_downloadview.sendfile`` is a port of
+  `django-sendfile`'s ``sendfile`` function. The documentation contains notes
+  about migrating from `django-sendfile` to `django-downloadview`.
+
+
+1.4 (2013-11-24)
+----------------
+
+Bugfixes and documentation features.
+
+- Bugfix #43 - ``ObjectDownloadView`` returns HTTP 404 if model instance's file
+  field is empty (was HTTP 500).
+
+- Bugfix #7 - Special characters in file names (``Content-Disposition`` header)
+  are urlencoded. An US-ASCII fallback is also provided.
+
+- Feature #10 - `django-downloadview` is registered on djangopackages.com.
+
+- Feature #65 - INSTALL documentation shows "known good set" (KGS) of versions,
+  i.e. versions that have been used in test environment.
+
+
+1.3 (2013-11-08)
+----------------
+
+Big refactoring around middleware configuration, API readability and
+documentation.
+
+- Bugfix #57 - ``PathDownloadView`` opens files in binary mode (was text mode).
+
+- Bugfix #48 - Fixed ``basename`` assertion in ``assert_download_response``:
+  checks ``Content-Disposition`` header.
+
+- Bugfix #49 - Fixed ``content`` assertion in ``assert_download_response``:
+  checks only response's ``streaming_content`` attribute.
+
+- Bugfix #60 - ``VirtualFile.__iter__`` uses ``force_bytes()`` to support both
+  "text-mode" and "binary-mode" content.
+  See https://code.djangoproject.com/ticket/21321
+
+- Feature #50 - Introduced ``django_downloadview.DownloadDispatcherMiddleware``
+  that iterates over a list of configurable download middlewares. Allows to
+  plug several download middlewares with different configurations.
+
+  This middleware is mostly dedicated to internal usage. It is used by
+  ``SmartDownloadMiddleware`` described below.
+
+- Feature #42 - Documentation shows how to stream generated content (yield).
+  Introduced ``django_downloadview.StringIteratorIO``.
+
+- Refactoring #51 - Dropped support of Python 2.6
+
+- Refactoring #25 - Introduced ``django_downloadview.SmartDownloadMiddleware``
+  which allows to setup multiple optimization rules for one backend.
+
+  Deprecates the following settings related to previous single-and-global
+  middleware:
+
+  * ``NGINX_DOWNLOAD_MIDDLEWARE_MEDIA_ROOT``
+  * ``NGINX_DOWNLOAD_MIDDLEWARE_MEDIA_URL``
+  * ``NGINX_DOWNLOAD_MIDDLEWARE_EXPIRES``
+  * ``NGINX_DOWNLOAD_MIDDLEWARE_WITH_BUFFERING``
+  * ``NGINX_DOWNLOAD_MIDDLEWARE_LIMIT_RATE``
+
+- Refactoring #52 - ObjectDownloadView now inherits from SingleObjectMixin and
+  BaseDownloadView (was DownloadMixin and BaseDetailView).
+  Simplified DownloadMixin.render_to_response() signature.
+
+- Refactoring #40 - Documentation includes examples from demo project.
+
+- Refactoring #39 - Documentation focuses on usage, rather than API. Improved
+  narrative documentation.
+
+- Refactoring #53 - Added base classes in ``django_downloadview.middlewares``,
+  such as ``ProxiedDownloadMiddleware``.
+
+- Refactoring #54 - Expose most Python API directly in `django_downloadview`
+  package. Simplifies ``import`` statements in client applications.
+  Splitted nginx module in a package.
+
+- Added unit tests, improved code coverage.
+
+
+1.2 (2013-05-28)
+----------------
+
+Bugfixes and documentation improvements.
+
+- Bugfix #26 - Prevented computation of virtual file's size, unless the file
+  wrapper implements was_modified_since() method.
+
+- Bugfix #34 - Improved support of files that do not implement modification
+  time.
+
+- Bugfix #35 - Fixed README conversion from reStructuredText to HTML (PyPI).
+
+
+1.1 (2013-04-11)
+----------------
+
+Various improvements.
+Contains **backward incompatible changes.**
+
+- Added HTTPDownloadView to proxy to arbitrary URL.
+
+- Added VirtualDownloadView to support files living in memory.
+
+- Using StreamingHttpResponse introduced with Django 1.5. Makes Django 1.5 a
+  requirement!
+
+- Added ``django_downloadview.test.assert_download_response`` utility.
+
+- Download views and response now use file wrappers. Most logic around file
+  attributes, formerly in views, moved to wrappers.
+
+- Replaced DownloadView by PathDownloadView and StorageDownloadView. Use the
+  right one depending on the use case.
+
+
+1.0 (2012-12-04)
+----------------
+
+- Introduced optimizations for Nginx X-Accel: a middleware and a decorator
+- Introduced generic views: DownloadView and ObjectDownloadView
+- Initialized project
+
+
+.. rubric:: Notes & references
+
+.. target-notes::
+
+.. _`milestones`: https://github.com/benoitbryon/django-downloadview/milestones
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..26d8289
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,94 @@
+############
+Contributing
+############
+
+This document provides guidelines for people who want to contribute to
+`django-downloadview`.
+
+
+**************
+Create tickets
+**************
+
+Please use the `bugtracker`_ **before** starting some work:
+
+* check if the bug or feature request has already been filed. It may have been
+  answered too!
+
+* else create a new ticket.
+
+* if you plan to contribute, tell us, so that we are given an opportunity to
+  give feedback as soon as possible.
+
+* Then, in your commit messages, reference the ticket with some
+  ``refs #TICKET-ID`` syntax.
+
+
+******************
+Use topic branches
+******************
+
+* Work in branches.
+
+* Prefix your branch with the ticket ID corresponding to the issue. As an
+  example, if you are working on ticket #23 which is about contribute
+  documentation, name your branch like ``23-contribute-doc``.
+
+* If you work in a development branch and want to refresh it with changes from
+  master, please `rebase`_ or `merge-based rebase`_, i.e. do not merge master.
+
+
+***********
+Fork, clone
+***********
+
+Clone `django-downloadview` repository (adapt to use your own fork):
+
+.. code:: sh
+
+   git clone git at github.com:benoitbryon/django-downloadview.git
+   cd django-downloadview/
+
+
+*************
+Usual actions
+*************
+
+The `Makefile` is the reference card for usual actions in development
+environment:
+
+* Install development toolkit with `pip`_: ``make develop``.
+
+* Run tests with `tox`_: ``make test``.
+
+* Build documentation: ``make documentation``. It builds `Sphinx`_
+  documentation in `var/docs/html/index.html`.
+
+* Release project with `zest.releaser`_: ``make release``.
+
+* Cleanup local repository: ``make clean``, ``make distclean`` and
+  ``make maintainer-clean``.
+
+See also ``make help``.
+
+
+*********************
+Demo project included
+*********************
+
+The `demo` included in project's repository is part of the tests and
+documentation. Maintain it along with code and documentation.
+
+
+.. rubric:: Notes & references
+
+.. target-notes::
+
+.. _`bugtracker`: 
+   https://github.com/benoitbryon/django-downloadview/issues
+.. _`rebase`: http://git-scm.com/book/en/Git-Branching-Rebasing
+.. _`merge-based rebase`: http://tech.novapost.fr/psycho-rebasing-en.html
+.. _`pip`: https://pypi.python.org/pypi/pip/
+.. _`tox`: http://tox.testrun.org
+.. _`Sphinx`: https://pypi.python.org/pypi/Sphinx/
+.. _`zest.releaser`: https://pypi.python.org/pypi/zest.releaser/
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..780e285
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,88 @@
+#######
+Install
+#######
+
+.. note::
+
+   If you want to install a development environment, please see
+   :doc:`/contributing`.
+
+
+************
+Requirements
+************
+
+`django-downloadview` has been tested with `Python`_ 2.7, 3.3 and 3.4. Other
+versions may work, but they are not part of the test suite at the moment.
+
+Installing `django-downloadview` will automatically trigger the installation of
+the following requirements:
+
+.. literalinclude:: /../setup.py
+   :language: python
+   :start-after: BEGIN requirements
+   :end-before: END requirements
+
+
+************
+As a library
+************
+
+In most cases, you will use `django-downloadview` as a dependency of another
+project. In such a case, you should add `django-downloadview` in your main
+project's requirements. Typically in :file:`setup.py`:
+
+.. code:: python
+
+   from setuptools import setup
+
+   setup(
+       install_requires=[
+           'django-downloadview',
+           #...
+       ]
+       # ...
+   )
+
+Then when you install your main project with your favorite package manager
+(like `pip`_), `django-downloadview` and its recursive dependencies will
+automatically be installed.
+
+
+**********
+Standalone
+**********
+
+You can install `django-downloadview` with your favorite Python package
+manager. As an example with `pip`_:
+
+.. code:: sh
+
+   pip install django-downloadview
+
+
+*****
+Check
+*****
+
+Check `django-downloadview` has been installed:
+
+.. code:: sh
+
+   python -c "import django_downloadview;print(django_downloadview.__version__)"
+
+You should get installed `django-downloadview`'s version.
+
+
+.. rubric:: Notes & references
+
+.. seealso::
+
+   * :doc:`/settings`
+   * :doc:`/about/changelog`
+   * :doc:`/about/license`
+
+.. target-notes::
+
+.. _`Python`: https://www.python.org/
+.. _`pip`: https://pip.pypa.io/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b0c9234
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,31 @@
+#######
+License
+#######
+
+Copyright (c) 2012-2014, Benoît Bryon.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+* Neither the name of django-downloadview nor the names of its contributors
+  may be used to endorse or promote products derived from this software without
+  specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..d52c1c3
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,9 @@
+recursive-include django_downloadview *
+global-exclude *.pyc
+include AUTHORS
+include CHANGELOG
+include CONTRIBUTING.rst
+include INSTALL
+include LICENSE
+include README.rst
+include VERSION
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..e61fc6a
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,67 @@
+Metadata-Version: 1.1
+Name: django-downloadview
+Version: 1.8
+Summary: Serve files with Django and reverse-proxies.
+Home-page: https://django-downloadview.readthedocs.org/
+Author: Benoît Bryon
+Author-email: benoit at marmelune.net
+License: BSD
+Description: ###################
+        django-downloadview
+        ###################
+        
+        `django-downloadview` makes it easy to serve files with `Django`_:
+        
+        * you manage files with Django (permissions, filters, generation, ...);
+        
+        * files are stored somewhere or generated somehow (local filesystem, remote
+          storage, memory...);
+        
+        * `django-downloadview` helps you stream the files with very little code;
+        
+        * `django-downloadview` helps you improve performances with reverse proxies,
+          via mechanisms such as Nginx's X-Accel or Apache's X-Sendfile.
+        
+        
+        *******
+        Example
+        *******
+        
+        Let's serve a file stored in a file field of some model:
+        
+        .. code:: python
+        
+           from django.conf.urls import url, url_patterns
+           from django_downloadview import ObjectDownloadView
+           from demoproject.download.models import Document  # A model with a FileField
+        
+           # ObjectDownloadView inherits from django.views.generic.BaseDetailView.
+           download = ObjectDownloadView.as_view(model=Document, file_field='file')
+        
+           url_patterns = ('',
+               url('^download/(?P<slug>[A-Za-z0-9_-]+)/$', download, name='download'),
+           )
+        
+        
+        *********
+        Resources
+        *********
+        
+        * Documentation: http://django-downloadview.readthedocs.org
+        * PyPI page: http://pypi.python.org/pypi/django-downloadview
+        * Code repository: https://github.com/benoitbryon/django-downloadview
+        * Bugtracker: https://github.com/benoitbryon/django-downloadview/issues
+        * Continuous integration: https://travis-ci.org/benoitbryon/django-downloadview
+        * Roadmap: https://github.com/benoitbryon/django-downloadview/milestones
+        
+        
+        .. _`Django`: https://djangoproject.com
+        
+Keywords: file stream download FileField ImageField x-accel x-accel-redirect x-sendfile sendfile mod_xsendfile offload
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Framework :: Django
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..c5c7909
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,50 @@
+###################
+django-downloadview
+###################
+
+`django-downloadview` makes it easy to serve files with `Django`_:
+
+* you manage files with Django (permissions, filters, generation, ...);
+
+* files are stored somewhere or generated somehow (local filesystem, remote
+  storage, memory...);
+
+* `django-downloadview` helps you stream the files with very little code;
+
+* `django-downloadview` helps you improve performances with reverse proxies,
+  via mechanisms such as Nginx's X-Accel or Apache's X-Sendfile.
+
+
+*******
+Example
+*******
+
+Let's serve a file stored in a file field of some model:
+
+.. code:: python
+
+   from django.conf.urls import url, url_patterns
+   from django_downloadview import ObjectDownloadView
+   from demoproject.download.models import Document  # A model with a FileField
+
+   # ObjectDownloadView inherits from django.views.generic.BaseDetailView.
+   download = ObjectDownloadView.as_view(model=Document, file_field='file')
+
+   url_patterns = ('',
+       url('^download/(?P<slug>[A-Za-z0-9_-]+)/$', download, name='download'),
+   )
+
+
+*********
+Resources
+*********
+
+* Documentation: http://django-downloadview.readthedocs.org
+* PyPI page: http://pypi.python.org/pypi/django-downloadview
+* Code repository: https://github.com/benoitbryon/django-downloadview
+* Bugtracker: https://github.com/benoitbryon/django-downloadview/issues
+* Continuous integration: https://travis-ci.org/benoitbryon/django-downloadview
+* Roadmap: https://github.com/benoitbryon/django-downloadview/milestones
+
+
+.. _`Django`: https://djangoproject.com
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..6259340
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.8
diff --git a/django_downloadview.egg-info/PKG-INFO b/django_downloadview.egg-info/PKG-INFO
new file mode 100644
index 0000000..e61fc6a
--- /dev/null
+++ b/django_downloadview.egg-info/PKG-INFO
@@ -0,0 +1,67 @@
+Metadata-Version: 1.1
+Name: django-downloadview
+Version: 1.8
+Summary: Serve files with Django and reverse-proxies.
+Home-page: https://django-downloadview.readthedocs.org/
+Author: Benoît Bryon
+Author-email: benoit at marmelune.net
+License: BSD
+Description: ###################
+        django-downloadview
+        ###################
+        
+        `django-downloadview` makes it easy to serve files with `Django`_:
+        
+        * you manage files with Django (permissions, filters, generation, ...);
+        
+        * files are stored somewhere or generated somehow (local filesystem, remote
+          storage, memory...);
+        
+        * `django-downloadview` helps you stream the files with very little code;
+        
+        * `django-downloadview` helps you improve performances with reverse proxies,
+          via mechanisms such as Nginx's X-Accel or Apache's X-Sendfile.
+        
+        
+        *******
+        Example
+        *******
+        
+        Let's serve a file stored in a file field of some model:
+        
+        .. code:: python
+        
+           from django.conf.urls import url, url_patterns
+           from django_downloadview import ObjectDownloadView
+           from demoproject.download.models import Document  # A model with a FileField
+        
+           # ObjectDownloadView inherits from django.views.generic.BaseDetailView.
+           download = ObjectDownloadView.as_view(model=Document, file_field='file')
+        
+           url_patterns = ('',
+               url('^download/(?P<slug>[A-Za-z0-9_-]+)/$', download, name='download'),
+           )
+        
+        
+        *********
+        Resources
+        *********
+        
+        * Documentation: http://django-downloadview.readthedocs.org
+        * PyPI page: http://pypi.python.org/pypi/django-downloadview
+        * Code repository: https://github.com/benoitbryon/django-downloadview
+        * Bugtracker: https://github.com/benoitbryon/django-downloadview/issues
+        * Continuous integration: https://travis-ci.org/benoitbryon/django-downloadview
+        * Roadmap: https://github.com/benoitbryon/django-downloadview/milestones
+        
+        
+        .. _`Django`: https://djangoproject.com
+        
+Keywords: file stream download FileField ImageField x-accel x-accel-redirect x-sendfile sendfile mod_xsendfile offload
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Framework :: Django
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/django_downloadview.egg-info/SOURCES.txt b/django_downloadview.egg-info/SOURCES.txt
new file mode 100644
index 0000000..56d9021
--- /dev/null
+++ b/django_downloadview.egg-info/SOURCES.txt
@@ -0,0 +1,50 @@
+AUTHORS
+CHANGELOG
+CONTRIBUTING.rst
+INSTALL
+LICENSE
+MANIFEST.in
+README.rst
+VERSION
+setup.py
+django_downloadview/__init__.py
+django_downloadview/api.py
+django_downloadview/decorators.py
+django_downloadview/exceptions.py
+django_downloadview/files.py
+django_downloadview/io.py
+django_downloadview/middlewares.py
+django_downloadview/response.py
+django_downloadview/shortcuts.py
+django_downloadview/test.py
+django_downloadview/utils.py
+django_downloadview.egg-info/PKG-INFO
+django_downloadview.egg-info/SOURCES.txt
+django_downloadview.egg-info/dependency_links.txt
+django_downloadview.egg-info/not-zip-safe
+django_downloadview.egg-info/pbr.json
+django_downloadview.egg-info/requires.txt
+django_downloadview.egg-info/top_level.txt
+django_downloadview/apache/__init__.py
+django_downloadview/apache/decorators.py
+django_downloadview/apache/middlewares.py
+django_downloadview/apache/response.py
+django_downloadview/apache/tests.py
+django_downloadview/lighttpd/__init__.py
+django_downloadview/lighttpd/decorators.py
+django_downloadview/lighttpd/middlewares.py
+django_downloadview/lighttpd/response.py
+django_downloadview/lighttpd/tests.py
+django_downloadview/nginx/__init__.py
+django_downloadview/nginx/decorators.py
+django_downloadview/nginx/middlewares.py
+django_downloadview/nginx/response.py
+django_downloadview/nginx/settings.py
+django_downloadview/nginx/tests.py
+django_downloadview/views/__init__.py
+django_downloadview/views/base.py
+django_downloadview/views/http.py
+django_downloadview/views/object.py
+django_downloadview/views/path.py
+django_downloadview/views/storage.py
+django_downloadview/views/virtual.py
\ No newline at end of file
diff --git a/django_downloadview.egg-info/dependency_links.txt b/django_downloadview.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_downloadview.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/django_downloadview.egg-info/not-zip-safe b/django_downloadview.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_downloadview.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/django_downloadview.egg-info/pbr.json b/django_downloadview.egg-info/pbr.json
new file mode 100644
index 0000000..fbac6f8
--- /dev/null
+++ b/django_downloadview.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": false, "git_version": "bdf8e6e"}
\ No newline at end of file
diff --git a/django_downloadview.egg-info/requires.txt b/django_downloadview.egg-info/requires.txt
new file mode 100644
index 0000000..2895f88
--- /dev/null
+++ b/django_downloadview.egg-info/requires.txt
@@ -0,0 +1,7 @@
+Django>=1.5
+requests
+setuptools
+six
+
+[test]
+tox
diff --git a/django_downloadview.egg-info/top_level.txt b/django_downloadview.egg-info/top_level.txt
new file mode 100644
index 0000000..1705dc6
--- /dev/null
+++ b/django_downloadview.egg-info/top_level.txt
@@ -0,0 +1 @@
+django_downloadview
diff --git a/django_downloadview/__init__.py b/django_downloadview/__init__.py
new file mode 100644
index 0000000..f25b9e5
--- /dev/null
+++ b/django_downloadview/__init__.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+"""Serve files with Django and reverse proxies."""
+import pkg_resources
+
+
+#: Module version, as defined in PEP-0396.
+__version__ = pkg_resources.get_distribution(__package__.replace('-', '_')) \
+                           .version
+
+
+# API shortcuts.
+from django_downloadview.api import *  # NoQA
diff --git a/django_downloadview/apache/__init__.py b/django_downloadview/apache/__init__.py
new file mode 100644
index 0000000..ec284eb
--- /dev/null
+++ b/django_downloadview/apache/__init__.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+"""Optimizations for Apache.
+
+See also `documentation of mod_xsendfile for Apache
+<https://tn123.org/mod_xsendfile/>`_ and :doc:`narrative documentation about
+Apache optimizations </optimizations/apache>`.
+
+"""
+# API shortcuts.
+from django_downloadview.apache.decorators import x_sendfile  # NoQA
+from django_downloadview.apache.response import XSendfileResponse  # NoQA
+from django_downloadview.apache.tests import assert_x_sendfile  # NoQA
+from django_downloadview.apache.middlewares import XSendfileMiddleware  # NoQA
diff --git a/django_downloadview/apache/decorators.py b/django_downloadview/apache/decorators.py
new file mode 100644
index 0000000..7af7e3d
--- /dev/null
+++ b/django_downloadview/apache/decorators.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+"""Decorators to apply Apache X-Sendfile on a specific view."""
+from django_downloadview.decorators import DownloadDecorator
+from django_downloadview.apache.middlewares import XSendfileMiddleware
+
+
+def x_sendfile(view_func, *args, **kwargs):
+    """Apply
+    :class:`~django_downloadview.apache.middlewares.XSendfileMiddleware` to
+    ``view_func``.
+
+    Proxies (``*args``, ``**kwargs``) to middleware constructor.
+
+    """
+    decorator = DownloadDecorator(XSendfileMiddleware)
+    return decorator(view_func, *args, **kwargs)
diff --git a/django_downloadview/apache/middlewares.py b/django_downloadview/apache/middlewares.py
new file mode 100644
index 0000000..ee854b3
--- /dev/null
+++ b/django_downloadview/apache/middlewares.py
@@ -0,0 +1,30 @@
+from django_downloadview.apache.response import XSendfileResponse
+from django_downloadview.middlewares import (ProxiedDownloadMiddleware,
+                                             NoRedirectionMatch)
+
+
+class XSendfileMiddleware(ProxiedDownloadMiddleware):
+    """Configurable middleware, for use in decorators or in global middlewares.
+
+    Standard Django middlewares are configured globally via settings. Instances
+    of this class are to be configured individually. It makes it possible to
+    use this class as the factory in
+    :py:class:`django_downloadview.decorators.DownloadDecorator`.
+
+    """
+    def __init__(self, source_dir=None, source_url=None, destination_dir=None):
+        """Constructor."""
+        super(XSendfileMiddleware, self).__init__(source_dir,
+                                                  source_url,
+                                                  destination_dir)
+
+    def process_download_response(self, request, response):
+        """Replace DownloadResponse instances by XSendfileResponse ones."""
+        try:
+            redirect_url = self.get_redirect_url(response)
+        except NoRedirectionMatch:
+            return response
+        return XSendfileResponse(file_path=redirect_url,
+                                 content_type=response['Content-Type'],
+                                 basename=response.basename,
+                                 attachment=response.attachment)
diff --git a/django_downloadview/apache/response.py b/django_downloadview/apache/response.py
new file mode 100644
index 0000000..9a37d8e
--- /dev/null
+++ b/django_downloadview/apache/response.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+"""Apache's specific responses."""
+import os.path
+
+from django_downloadview.response import (ProxiedDownloadResponse,
+                                          content_disposition)
+
+
+class XSendfileResponse(ProxiedDownloadResponse):
+    "Delegates serving file to Apache via X-Sendfile header."
+    def __init__(self, file_path, content_type, basename=None,
+                 attachment=True):
+        """Return a HttpResponse with headers for Apache X-Sendfile."""
+        super(XSendfileResponse, self).__init__(content_type=content_type)
+        if attachment:
+            self.basename = basename or os.path.basename(file_path)
+            self['Content-Disposition'] = content_disposition(self.basename)
+        self['X-Sendfile'] = file_path
diff --git a/django_downloadview/apache/tests.py b/django_downloadview/apache/tests.py
new file mode 100644
index 0000000..0aa17b0
--- /dev/null
+++ b/django_downloadview/apache/tests.py
@@ -0,0 +1,62 @@
+from six import iteritems
+from django_downloadview.apache.response import XSendfileResponse
+
+
+class XSendfileValidator(object):
+    """Utility class to validate XSendfileResponse instances.
+
+    See also :py:func:`assert_x_sendfile` shortcut function.
+
+    """
+    def __call__(self, test_case, response, **assertions):
+        """Assert that ``response`` is a valid X-Sendfile response.
+
+        Optional ``assertions`` dictionary can be used to check additional
+        items:
+
+        * ``basename``: the basename of the file in the response.
+
+        * ``content_type``: the value of "Content-Type" header.
+
+        * ``file_path``: the value of "X-Sendfile" header.
+
+        """
+        self.assert_x_sendfile_response(test_case, response)
+        for key, value in iteritems(assertions):
+            assert_func = getattr(self, 'assert_%s' % key)
+            assert_func(test_case, response, value)
+
+    def assert_x_sendfile_response(self, test_case, response):
+        test_case.assertTrue(isinstance(response, XSendfileResponse))
+
+    def assert_basename(self, test_case, response, value):
+        test_case.assertEqual(response.basename, value)
+
+    def assert_content_type(self, test_case, response, value):
... 2437 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-downloadview.git



More information about the Python-modules-commits mailing list