Пример #1
0
 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))
Пример #2
0
 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)