def post(self):
		title = self.request.get("subject")
		content = self.request.get("content")
		if title and content:
			newcontent = BlogDb(title = title, content = content)
			a = newcontent.put()
			post_id = a.id()
			memcache.delete(POST_KEY)
			self.redirect('/blog/{}'.format(post_id))
		else:
			error = "Need both the fields to be filled"
			self.render_front(title,content,error)
 def get(self,*args):
     jstr = {"content": "","created": "","last_modified": "","subject":""}
     self.response.headers["Content-Type"] = "application/json"
     if args:
         singlepost = BlogDb.get_by_id(int(args[0]))
         json_str = post_json(singlepost)
         self.response.out.write(json.dumps(json_str))
     else:
         allposts = memcache.get(POST_KEY)
         if allposts is None:
             allposts = db.GqlQuery("SELECT * FROM BlogDb ORDER BY date_published DESC LIMIT 10")
             memcache.set(POST_KEY,allposts)
         jall = []
         for singlepost in allposts:
             json_str = post_json(singlepost)
             jall.append(json_str) 
         self.response.out.write(json.dumps(jall))
 def get(self,post_id):
     sp = memcache.get(post_id)
     if sp is None:
         sp = BlogDb.get_by_id(int(post_id))
         memcache.set(post_id,sp)
     self.render_post(sp.title,sp.content,sp.date_modified,sp.date_published)