summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorHiroki KIYOHARA <hirokiky@gmail.com>2014-07-26 12:06:48 +0200
committerJames Bennett <james@b-list.org>2014-07-26 14:53:31 +0200
commitdf678b750026db2f9bc0108dddead4c35a9cfba3 (patch)
treee8c10337873ad9ddf55e4451c086d806a100bd0d /django
parent0d8d4fe9b4968364e40eb05eae5c7d30f9514516 (diff)
[1.7.x] Fixed code to solve #23070 problem
Added a class to wrap callable in settings: * Not to call in the debug page (#21345). * Not to break the debug page if the callable forbidding to set attributes (#23070). Thanks @bmispelon for giving me some advice. Backport of d0889863de50d65659f56f0b9ea0672a8b6482a1 from master.
Diffstat (limited to 'django')
-rw-r--r--django/views/debug.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/django/views/debug.py b/django/views/debug.py
index efb3079d7e..13992e9f98 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -31,6 +31,19 @@ def linebreak_iter(template_source):
yield len(template_source) + 1
+class CallableSettingWrapper(object):
+ """ Object to wrap callable appearing in settings
+
+ * Not to call in the debug page (#21345).
+ * Not to break the debug page if the callable forbidding to set attributes (#23070).
+ """
+ def __init__(self, callable_setting):
+ self._wrapped = callable_setting
+
+ def __repr__(self):
+ return repr(self._wrapped)
+
+
def cleanse_setting(key, value):
"""Cleanse an individual setting key/value of sensitive content.
@@ -50,7 +63,8 @@ def cleanse_setting(key, value):
cleansed = value
if callable(cleansed):
- cleansed.do_not_call_in_templates = True
+ # For fixing #21345 and #23070
+ cleansed = CallableSettingWrapper(cleansed)
return cleansed