Nicer formatting of status

This commit is contained in:
Tom Christie 2010-12-30 17:32:52 +00:00
parent abb55a4909
commit a78f578475
2 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,5 @@
from django.template import Context, loader from django.template import Context, loader
from django.core.handlers.wsgi import STATUS_CODE_TEXT
import json import json
class BaseEmitter(object): class BaseEmitter(object):
@ -17,6 +18,7 @@ class TemplatedEmitter(BaseEmitter):
context = Context({ context = Context({
'content': content, 'content': content,
'status': self.status, 'status': self.status,
'reason': STATUS_CODE_TEXT.get(self.status, ''),
'headers': self.headers, 'headers': self.headers,
'resource_name': self.resource.__class__.__name__, 'resource_name': self.resource.__class__.__name__,
'resource_doc': self.resource.__doc__ 'resource_doc': self.resource.__doc__

View File

@ -10,8 +10,8 @@
<body> <body>
<h1>{{ resource_name }}</h1> <h1>{{ resource_name }}</h1>
<p>{{ resource_doc }}</p> <p>{{ resource_doc }}</p>
<pre>{% autoescape off %}HTTP Status {{ status }} <pre>{% autoescape off %}<b>{{ status }} {{ reason }}</b>
{% for key, val in headers.items %}{{ key }}: {{ val }} {% for key, val in headers.items %}<b>{{ key }}:</b> {{ val }}
{% endfor %} {% endfor %}
{{ content|urlize_quoted_links }}{% endautoescape %} </pre> {{ content|urlize_quoted_links }}{% endautoescape %} </pre>
</body> </body>