예제 #1
0
파일: blog.py 프로젝트: kafkahw/Wei-Blog
    def post(self):
        subject = self.request.get('subject')
        content = self.request.get('content')

        if subject and content:
            p = Post(parent = blog_key(), subject = subject, content = content)
            add_post(p)
            self.redirect('/blog/%s' % str(p.key().id()))
        else:
            error = "subject and content, please!"
            self.render("newpost.html", subject=subject, 
                                        content=content, 
                                        error=error,
                                        username=self.user.username)
예제 #2
0
파일: blog.py 프로젝트: kafkahw/Wei-Blog
def get_posts():

    # look into memcache first
    posts, age = age_get(MC_BLOG_KEY)

    # if not in memcache
    if posts is None:
        q = Post.all().order('-created').fetch(limit = FRONT_PAGE_LENTH)
        posts = list(q)
        age_set(MC_BLOG_KEY, posts)
        age = 0

    return posts, age