예제 #1
0
파일: Post.py 프로젝트: muntac/basic-blog
 def post(self):
     #Enter blog post in database
     subject = self.request.get("subject")
     content = self.request.get("content")
     if subject and content:
         a = BlogPost(subject = subject, content = content)
         keyblog = a.put()
         memcache.set("home",None)
         self.redirect("/blog/" + str(keyblog.id()) )
     else:
         error = "Post must have BOTH a subject and a content"
         self.render(subject = subject, content = content, error = error)
예제 #2
0
파일: Post.py 프로젝트: muntac/basic-blog
 def get(self, post_id):
     mempost = memcache.get(post_id)
     last_queried = 0
     if mempost is None:
         post = BlogPost.get_by_id(int(post_id))
         if not post:
             self.error(404)
             return
         memcache.set(post_id,( (post.subject,post.content,post.creationtime), time.time() ) )
     else:
         last_queried = time.time() - mempost[1]
         post = BlogPost(subject = mempost[0][0], content = mempost[0][1], creationtime = mempost[0][2])
     self.render("permalink.html", post = post, lasttime = last_queried)