Skip to content
Browse files

pretty print

  • Loading branch information...
1 parent d12fb26 commit 995910670fefac6fde8b8e07d3694f112857a903 Benjamin Golub committed
Showing with 6 additions and 3 deletions.
  1. +6 −3 blog.py
View
9 blog.py
@@ -10,6 +10,8 @@
import uuid
import wsgiref.handlers
+from django.utils import simplejson as json
+
from google.appengine.ext import db
from google.appengine.api import urlfetch
from google.appengine.api import users
@@ -80,13 +82,14 @@ def render(self, template_name, **kwargs):
"tags": entry.tags,
"link": "http://" + self.request.host + "/" + entry.slug,
} for entry in kwargs["entries"]]
- json = {
+ data = {
"entries": json_entries,
}
if "cursor" in kwargs:
- json["cursor"] = kwargs["cursor"]
+ data["cursor"] = kwargs["cursor"]
self.set_header("Content-Type", "text/javascript")
- self.write(json)
+ self.write(json.dumps(data, sort_keys=True, indent=4) if
+ self.get_argument("pretty", False) else data)
return
return tornado.web.RequestHandler.render(self, template_name, **kwargs)

0 comments on commit 9959106

Please sign in to comment.
Something went wrong with that request. Please try again.