Permalink
Browse files

json for exporting

  • Loading branch information...
Benjamin Golub
Benjamin Golub committed Mar 16, 2010
1 parent d4d4ba7 commit 970eb388b6ded26cca1003f4e69c7e77e5303cd2
Showing with 14 additions and 0 deletions.
  1. +14 −0 blog.py
View
14 blog.py
@@ -69,6 +69,20 @@ def render(self, template_name, **kwargs):
self.set_header("Content-Type", "application/atom+xml")
self.set_sup_header()
template_name = "atom.xml"
+ if "entries" in kwargs and format == "json":
+ json_entries = [{
+ "title": entry.title,
+ "slug": entry.slug,
+ "body": entry.body,
+ "author": entry.author.nickname(),
+ "published": entry.published.isoformat(),
+ "updated": entry.updated.isoformat(),
+ "tags": entry.tags,
+ "link": "http://" + self.request.host + "/e/" + entry.slug,
+ } for entry in kwargs["entries"]]
+ self.set_header("Content-Type", "text/javascript")
+ self.write({"entries": json_entries})
+ return
return tornado.web.RequestHandler.render(self, template_name, **kwargs)
def slugify(self, value):

0 comments on commit 970eb38

Please sign in to comment.