Fixed #822 -- Changed 500 view to use disclosure triangles instead of up/down arrows. Thanks, aaronsw
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1272 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6be0210763
commit
b1603563a3
|
@ -33,8 +33,8 @@ def technical_500_response(request, exc_type, exc_value, tb):
|
||||||
'pre_context_lineno' : pre_context_lineno,
|
'pre_context_lineno' : pre_context_lineno,
|
||||||
})
|
})
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
|
|
||||||
# Turn the settings module into a dict, filtering out anything that
|
# Turn the settings module into a dict, filtering out anything that
|
||||||
# matches HIDDEN_SETTINGS along the way.
|
# matches HIDDEN_SETTINGS along the way.
|
||||||
settings_dict = {}
|
settings_dict = {}
|
||||||
for k in dir(settings):
|
for k in dir(settings):
|
||||||
|
@ -43,7 +43,7 @@ def technical_500_response(request, exc_type, exc_value, tb):
|
||||||
settings_dict[k] = '********************'
|
settings_dict[k] = '********************'
|
||||||
else:
|
else:
|
||||||
settings_dict[k] = getattr(settings, k)
|
settings_dict[k] = getattr(settings, k)
|
||||||
|
|
||||||
t = Template(TECHNICAL_500_TEMPLATE)
|
t = Template(TECHNICAL_500_TEMPLATE)
|
||||||
c = Context({
|
c = Context({
|
||||||
'exception_type' : exc_type.__name__,
|
'exception_type' : exc_type.__name__,
|
||||||
|
@ -53,7 +53,7 @@ def technical_500_response(request, exc_type, exc_value, tb):
|
||||||
'request' : request,
|
'request' : request,
|
||||||
'request_protocol' : os.environ.get("HTTPS") == "on" and "https" or "http",
|
'request_protocol' : os.environ.get("HTTPS") == "on" and "https" or "http",
|
||||||
'settings' : settings_dict,
|
'settings' : settings_dict,
|
||||||
|
|
||||||
})
|
})
|
||||||
return HttpResponseServerError(t.render(c))
|
return HttpResponseServerError(t.render(c))
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ def technical_404_response(request, exception):
|
||||||
tried = exception.args[0]['tried']
|
tried = exception.args[0]['tried']
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
tried = []
|
tried = []
|
||||||
|
|
||||||
t = Template(TECHNICAL_404_TEMPLATE)
|
t = Template(TECHNICAL_404_TEMPLATE)
|
||||||
c = Context({
|
c = Context({
|
||||||
'root_urlconf' : settings.ROOT_URLCONF,
|
'root_urlconf' : settings.ROOT_URLCONF,
|
||||||
|
@ -80,7 +80,7 @@ def technical_404_response(request, exception):
|
||||||
|
|
||||||
def _get_lines_from_file(filename, lineno, context_lines):
|
def _get_lines_from_file(filename, lineno, context_lines):
|
||||||
"""
|
"""
|
||||||
Returns context_lines before and after lineno from file.
|
Returns context_lines before and after lineno from file.
|
||||||
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -91,7 +91,7 @@ def _get_lines_from_file(filename, lineno, context_lines):
|
||||||
pre_context = [line.strip('\n') for line in source[lower_bound:lineno]]
|
pre_context = [line.strip('\n') for line in source[lower_bound:lineno]]
|
||||||
context_line = source[lineno].strip('\n')
|
context_line = source[lineno].strip('\n')
|
||||||
post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]]
|
post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]]
|
||||||
|
|
||||||
return lower_bound, pre_context, context_line, post_context
|
return lower_bound, pre_context, context_line, post_context
|
||||||
except (OSError, IOError):
|
except (OSError, IOError):
|
||||||
return None, [], None, []
|
return None, [], None, []
|
||||||
|
@ -147,23 +147,23 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function getElementsByClassName(oElm, strTagName, strClassName){
|
function getElementsByClassName(oElm, strTagName, strClassName){
|
||||||
// Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com
|
// Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com
|
||||||
var arrElements = (strTagName == "*" && document.all)? document.all :
|
var arrElements = (strTagName == "*" && document.all)? document.all :
|
||||||
oElm.getElementsByTagName(strTagName);
|
oElm.getElementsByTagName(strTagName);
|
||||||
var arrReturnElements = new Array();
|
var arrReturnElements = new Array();
|
||||||
strClassName = strClassName.replace(/\-/g, "\\-");
|
strClassName = strClassName.replace(/\-/g, "\\-");
|
||||||
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
|
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
|
||||||
var oElement;
|
var oElement;
|
||||||
for(var i=0; i<arrElements.length; i++){
|
for(var i=0; i<arrElements.length; i++){
|
||||||
oElement = arrElements[i];
|
oElement = arrElements[i];
|
||||||
if(oRegExp.test(oElement.className)){
|
if(oRegExp.test(oElement.className)){
|
||||||
arrReturnElements.push(oElement);
|
arrReturnElements.push(oElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (arrReturnElements)
|
return (arrReturnElements)
|
||||||
}
|
}
|
||||||
function hideAll(elems) {
|
function hideAll(elems) {
|
||||||
for (var e = 0; e < elems.length; e++) {
|
for (var e = 0; e < elems.length; e++) {
|
||||||
elems[e].style.display = 'none';
|
elems[e].style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
|
@ -183,8 +183,8 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
function varToggle(link, id) {
|
function varToggle(link, id) {
|
||||||
toggle('v' + id);
|
toggle('v' + id);
|
||||||
var s = link.getElementsByTagName('span')[0];
|
var s = link.getElementsByTagName('span')[0];
|
||||||
var uarr = String.fromCharCode(0x2191);
|
var uarr = String.fromCharCode(0x25b6);
|
||||||
var darr = String.fromCharCode(0x2193);
|
var darr = String.fromCharCode(0x25bc);
|
||||||
s.innerHTML = s.innerHTML == uarr ? darr : uarr;
|
s.innerHTML = s.innerHTML == uarr ? darr : uarr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
{% for frame in frames %}
|
{% for frame in frames %}
|
||||||
<li class="frame">
|
<li class="frame">
|
||||||
<code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code>
|
<code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code>
|
||||||
|
|
||||||
{% if frame.context_line %}
|
{% if frame.context_line %}
|
||||||
<div class="context" id="c{{ frame.id }}">
|
<div class="context" id="c{{ frame.id }}">
|
||||||
{% if frame.pre_context %}
|
{% if frame.pre_context %}
|
||||||
|
@ -237,10 +237,10 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if frame.vars %}
|
{% if frame.vars %}
|
||||||
<div class="commands">
|
<div class="commands">
|
||||||
<a href="#" onclick="return varToggle(this, '{{ frame.id }}')">Local vars <span>↓</span> </a>
|
<a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>▶</span> Local vars</a>
|
||||||
</div>
|
</div>
|
||||||
<table class="vars" id="v{{ frame.id }}">
|
<table class="vars" id="v{{ frame.id }}">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -266,7 +266,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
|
|
||||||
<div id="requestinfo">
|
<div id="requestinfo">
|
||||||
<h2>Request information</h2>
|
<h2>Request information</h2>
|
||||||
|
|
||||||
<h3 id="get-info">GET</h3>
|
<h3 id="get-info">GET</h3>
|
||||||
{% if request.GET %}
|
{% if request.GET %}
|
||||||
<table class="req">
|
<table class="req">
|
||||||
|
@ -288,7 +288,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No GET data<p>
|
<p>No GET data<p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h3 id="post-info">POST</h3>
|
<h3 id="post-info">POST</h3>
|
||||||
{% if request.POST %}
|
{% if request.POST %}
|
||||||
<table class="req">
|
<table class="req">
|
||||||
|
@ -310,7 +310,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No POST data<p>
|
<p>No POST data<p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h3 id="cookie-info">COOKIES</h3>
|
<h3 id="cookie-info">COOKIES</h3>
|
||||||
{% if request.COOKIES %}
|
{% if request.COOKIES %}
|
||||||
<table class="req">
|
<table class="req">
|
||||||
|
@ -332,7 +332,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No cookie data<p>
|
<p>No cookie data<p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h3 id="meta-info">META</h3>
|
<h3 id="meta-info">META</h3>
|
||||||
<table class="req">
|
<table class="req">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -434,12 +434,12 @@ TECHNICAL_404_TEMPLATE = """
|
||||||
<li>{{ pattern|escape }}</li>
|
<li>{{ pattern|escape }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
<p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p>
|
<p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{{ reason|escape }}</p>
|
<p>{{ reason|escape }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="explanation">
|
<div id="explanation">
|
||||||
<p>
|
<p>
|
||||||
You're seeing this error because you have <code>DEBUG = True</code> in
|
You're seeing this error because you have <code>DEBUG = True</code> in
|
||||||
|
|
Loading…
Reference in New Issue