def post(self): title = self.request.get("subject") blog = self.request.get("content") if title and blog: coords = utils.get_coords(self.request.remote_addr) newBlog = BlogPost(title=title, blog=blog, coords=coords) newBlog.put() FrontPage(update=True) val = newBlog.key().id() PermaLinkPage(update=newBlog) self.redirect("/blog/"+str(val)) else: error = "You need a title and blog entry!" self.render_blog(error=error,title=title)
def PermaLinkPage(update = None, page_number=0): key = "page_"+ str(page_number) keytime = key +"_time" singlePost = memcache.get(key) if update: memcache.set(key, update) memcache.set(keytime, time.time()) elif singlePost is None: singlePost = BlogPost.get_by_id(page_number) memcache.set(key, singlePost) memcache.set(keytime, time.time()) return singlePost