def post(self): valid_cookie = self.request.cookies.get('user_id') if valid_cookie: import globals if globals.users != None: subject = self.request.get("subject") contents = self.request.get("content") if subject and contents: s = Blog_db(parent = utils.blog_key(), subject = subject, content = contents) s.put() utils.cache_blog(True) self.redirect("/blog/%s" % str(s.key().id())) else: error = "We need both subject and content!" self.render("newpost.html", subject = subject, content = contents, error = error, user = globals.users) else: self.redirect('/')
def get(self): valid_cookie = self.request.cookies.get('user_id') if valid_cookie: import globals if globals.users != None: global time_start_blog; posts = memcache.get('blog_front') if not posts: posts = utils.cache_blog() time_start_blog = datetime.datetime.now() time_reload = datetime.datetime.now() total_time = time_reload - time_start_blog seconds = total_time.seconds sec_time = 'Queried: %s seconds ago' % seconds self.render("blog.html", posts = posts, time = sec_time, user = globals.users) else: self.redirect('/')