def get(self): msg = self.request.get('msg') if msg: template_values = { 'msg': msg } template = JINJA_ENVIRONMENT.get_template('info.html') self.response.write(template.render(template_values)) else: blog_name = self.request.get('blog_name') curs = Cursor(urlsafe=self.request.get('cursor')) tags = [] if blog_name == '': blogposts_query = BlogPost.query().order(-BlogPost.create_time) templist = [] for post in blogposts_query.fetch(): templist = templist + post.taglist tags = list(set(templist)) selectedblog='' else: blogposts_query = BlogPost.query(ancestor=blog_key(blog_name)).order(-BlogPost.create_time) blog_query = Blog.query().filter(Blog.blog_name == blog_name) selectedblog = blog_query.fetch()[0] blogposts, next_curs, more = blogposts_query.fetch_page(MAX_POST_PER_PAGE, start_cursor=curs) cur_url = '' if more and next_curs: cur_url = next_curs.urlsafe() user = users.get_current_user() if user: blogs_query = Blog.query(ancestor=user_key(user.email())).order(-Blog.create_time) blogs = blogs_query.fetch() url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: blogs = '' url = users.create_login_url(self.request.uri) url_linktext = 'Login' template_values = { 'user': user, 'blogs': blogs, 'selectedblog': selectedblog, 'blogposts': blogposts, 'url': url, 'url_linktext': url_linktext, 'cur_url': cur_url, 'tags': tags, } template = JINJA_ENVIRONMENT.get_template('index.html') self.response.write(template.render(template_values))
def get(self): blog_name = self.request.get('blog_name') blogs_query = Blog.query().order(-Blog.create_time) blogs_query = blogs_query.filter(Blog.blog_name == blog_name) blogs = blogs_query.fetch() blog = blogs[0] posts_query = BlogPost.query(ancestor=main.blog_key(blog_name)).order(-BlogPost.create_time) posts = posts_query.fetch() template_values = { 'blog': blog, 'posts': posts, 'back_url': self.request.uri } template = main.JINJA_ENVIRONMENT.get_template('rss.html') self.response.headers['Content-Type'] = 'text/plain' self.response.write(template.render(template_values))