mark methods passed through wsgi META with do_not_call_in_templates #1546

wants to merge 4 commits into


None yet

4 participants


WSGI servers such as Werkzeug pass callable methods that should NOT be called when the META structure is printed in places such as the debug response handler.

When a Django view throws an error (with DEBUG=True) and is hosted by Werkzeug, it causes the server to silently shut down because the Django error page is blindly calling the shutdown method in order to pretty print the result for the error page.

Django member

This also needs a ticket and test.

Django member

Hm. I'm not sure this is a such a good idea. It requires an iteration through META on every request, whether or not you're actually using Werkzeug. I don't like the idea of adding an overhead that everyone has to pay because of a side effect in the way Werkzeug works. I don't know that I have a better solution, but right now I'm -1 on merging this.


I agree that this is a bit wonky for Werkzeug to be passing a callabale in the environ dict, but it's unacceptable for Django to be blindly invoking that callable at any point. How about one of the following options:

a) iterate through the META structure only when DEBUG==True
b) delay iteration until we enter the debug handler view

My vote is for option b. Thoughts?

Django member

Since this has a -1 from jacob and clearly needs more discussion, please open a ticket and discuss there and then reopen a new pull request with the decided solution (if at all)

@apollo13 apollo13 closed this Sep 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment