def post(self): blog_subject = self.request.get('subject') blog_body = self.request.get('content') valid_subject = validate_blog_subject(blog_subject) valid_body = validate_blog_body(blog_body) if not (valid_subject and valid_body): error_subject = '' error_content = '' if not valid_subject: error_subject = 'Please add a valid subject.' if not valid_body: error_content = 'Please add valid content.' self.render('newpost.html', subject = blog_subject, content = blog_body, error_subject = error_subject, error_content = error_content, active_tab = 'active') else: blog_posting = BlogPosts(subject=blog_subject, content=blog_body) blog_posting.put() permalink_id = str(blog_posting.key().id()) #update memcache and redirect to permalink get_latest_postings(True) self.response.headers.add_header('Set-Cookie', 'render_time=; Path=/blog') self.redirect('/blog/'+ permalink_id)
def post(self): blog_subject = self.request.get('subject') blog_body = self.request.get('content') valid_subject = validate_blog_subject(blog_subject) valid_body = validate_blog_body(blog_body) if not (valid_subject and valid_body): error_subject = '' error_content = '' if not valid_subject: error_subject = 'Please add a valid subject.' if not valid_body: error_content = 'Please add valid content.' self.render('newpost.html', subject=blog_subject, content=blog_body, error_subject=error_subject, error_content=error_content, active_tab='active') else: blog_posting = BlogPosts(subject=blog_subject, content=blog_body) blog_posting.put() permalink_id = str(blog_posting.key().id()) #update memcache and redirect to permalink get_latest_postings(True) self.response.headers.add_header('Set-Cookie', 'render_time=; Path=/blog') self.redirect('/blog/' + permalink_id)
def get(self): blog_postings_data = get_latest_postings() render_time = blog_postings_data[1] time_since_page_generated = 'Queried %s seconds ago' % render_time #render page self.render('home.html', blog_postings = blog_postings_data[0], time_since_page_generated = time_since_page_generated, home_active_tab = 'active')
def get(self): blog_postings_data = get_latest_postings() render_time = blog_postings_data[1] time_since_page_generated = 'Queried %s seconds ago' % render_time #render page self.render('home.html', blog_postings=blog_postings_data[0], time_since_page_generated=time_since_page_generated, home_active_tab='active')