0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-25 13:10:14 +01:00

Added a flag in dummy_request() to inform middleware that the request is a dummy.

This is useful for middleware that perform destructive changes in
process_response(). They rightfully expect process_response() to only get called
once per thread, but it happens twice during a Page preview when running under
Django 1.10's middleware system. This flag lets the middleware know that they
should potentially skip their destructive operations.

Conflicts:
	wagtail/wagtailcore/models.py
This commit is contained in:
Robert Rollins 2017-09-11 15:59:47 -07:00 committed by Matt Westcott
parent 7c92ed7bad
commit c8b0fff586

View File

@ -1243,6 +1243,9 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
request = WSGIRequest(dummy_values)
# Add a flag to let middleware know that this is a dummy request.
request.is_dummy = True
# Apply middleware to the request
# Note that Django makes sure only one of the middleware settings are
# used in a project