Skip to content

Commit

Permalink
Merge pull request #206 from sevdog/upgrade-middleware-doc
Browse files Browse the repository at this point in the history
Update usage of middleware settings
  • Loading branch information
tari authored Jul 30, 2024
2 parents fba10f7 + c517202 commit 16b241d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
9 changes: 1 addition & 8 deletions django_downloadview/nginx/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
deprecated_middleware = "django_downloadview.nginx.XAccelRedirectMiddleware"


def get_middlewares():
try:
return settings.MIDDLEWARE
except AttributeError:
return settings.MIDDLEWARE_CLASSES


if deprecated_middleware in get_middlewares():
if deprecated_middleware in settings.MIDDLEWARE:
raise ImproperlyConfigured(
"{deprecated_middleware} middleware has been renamed as of "
"django-downloadview version 1.3. You may use "
Expand Down
2 changes: 1 addition & 1 deletion docs/django-sendfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Here are tips to migrate from `django-sendfile` to `django-downloadview`...
* setup ``DOWNLOADVIEW_RULES``. It replaces ``SENDFILE_ROOT`` and can do
more.
* register ``django_downloadview.SmartDownloadMiddleware`` in
``MIDDLEWARE_CLASSES``.
``MIDDLEWARE``.

4. Change your tests if any. You can no longer use `django-senfile`'s
``development`` backend. See :doc:`/testing` for `django-downloadview`'s
Expand Down
4 changes: 2 additions & 2 deletions docs/optimizations/apache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Setup XSendfile middlewares
***************************

Make sure ``django_downloadview.SmartDownloadMiddleware`` is in
``MIDDLEWARE_CLASSES`` of your `Django` settings.
``MIDDLEWARE`` of your `Django` settings.

Example:

Expand Down Expand Up @@ -128,4 +128,4 @@ setup.

.. target-notes::

.. _`Apache mod_xsendfile documentation`: https://tn123.org/mod_xsendfile/
.. _`Apache mod_xsendfile documentation`: https://tn123.org/mod_xsendfile/
2 changes: 1 addition & 1 deletion docs/optimizations/lighttpd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Setup XSendfile middlewares
***************************

Make sure ``django_downloadview.SmartDownloadMiddleware`` is in
``MIDDLEWARE_CLASSES`` of your `Django` settings.
``MIDDLEWARE`` of your `Django` settings.

Example:

Expand Down
8 changes: 4 additions & 4 deletions docs/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ There is no need to register this application in ``INSTALLED_APPS``.


******************
MIDDLEWARE_CLASSES
MIDDLEWARE
******************

If you plan to setup :doc:`reverse-proxy optimizations </optimizations/index>`,
add ``django_downloadview.SmartDownloadMiddleware`` to ``MIDDLEWARE_CLASSES``.
add ``django_downloadview.SmartDownloadMiddleware`` to ``MIDDLEWARE``.
It is a response middleware. Move it after middlewares that compute the
response content such as gzip middleware.

Expand Down Expand Up @@ -91,7 +91,7 @@ Example:
See :doc:`/optimizations/index` for a list of available backends (middlewares).

When ``django_downloadview.SmartDownloadMiddleware`` is in your
``MIDDLEWARE_CLASSES``, this setting must be explicitely configured (no default
``MIDDLEWARE``, this setting must be explicitely configured (no default
value). Else, you can ignore this setting.


Expand Down Expand Up @@ -119,5 +119,5 @@ See :doc:`/optimizations/index` for details about builtin backends
(middlewares) and their options.

When ``django_downloadview.SmartDownloadMiddleware`` is in your
``MIDDLEWARE_CLASSES``, this setting must be explicitely configured (no default
``MIDDLEWARE``, this setting must be explicitely configured (no default
value). Else, you can ignore this setting.
1 change: 0 additions & 1 deletion tests/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class DeprecatedAPITestCase(django.test.SimpleTestCase):
def test_nginx_x_accel_redirect_middleware(self):
"XAccelRedirectMiddleware in settings triggers ImproperlyConfigured."
with override_settings(
MIDDLEWARE_CLASSES=["django_downloadview.nginx.XAccelRedirectMiddleware"],
MIDDLEWARE=["django_downloadview.nginx.XAccelRedirectMiddleware"],
):
with self.assertRaises(ImproperlyConfigured):
Expand Down

0 comments on commit 16b241d

Please sign in to comment.