예제 #1
0
def comment():
    form = request.form
    BlogComment.new(form)
    return redirect(url_for('.view', blog_id=form.get("blog_id")))


# 传统  : 传递回来一个页面
# 现代的方法呢: 是做成服务 访问一个网址,返回了json
# 1. 不同服务,可以用不用的语言
# 2. 拆分服务 业务里面 有一些部分很耗费性能,有一些部分不怎么耗费性能
# 在传统做法里面 n个app 对应不同的用户,让他访问不同的app
# 每个服务独立,复制的单位,是以服务为基础的 微服务,SOA,面向服务的架构
예제 #2
0
def view(post_id=None,
         comment_id=None,
         comment=None,
         post=None,
         comments=None,
         user=None):
    '''
  View and comment on a post.
  '''
    if request.form.get('cancel'):
        return redirect(url_for('view', post_id=post_id) + '#comments')

    user = user or None
    post = post.get() if post else None
    comments = comments or None
    comment = comment.get() if comment else None
    if user and post and request.method == 'POST':
        comment = comment or BlogComment(parent=post.key)
        comment.fill(content=request.form.get('content', None),
                     author=user.key)
        if not comment.empty('content'):
            comment.put()
            return redirect(
                url_for('view', post_id=post_id) + '#' + comment.uid)
        else:
            return render_template('view.html',
                                   page=None,
                                   user=user,
                                   post=post,
                                   comments=comments,
                                   comment_id=comment_id)
    elif post:
        return render_template('view.html',
                               page=None,
                               user=user,
                               post=post,
                               comments=comments,
                               comment_id=comment_id)
    else:
        return abort(404)
예제 #3
0
def view(blog_id):
    comments = BlogComment.find_all(blog_id=blog_id)
    blog = Blog.find(blog_id)
    return render_template("blog/blog_view.html", blog=blog, comments=comments)
예제 #4
0
def comment():
    form = request.form
    BlogComment.new(form)
    return redirect(url_for('.view', blog_id=form.get("blog_id")))
예제 #5
0
def comment():
    form = request.form
    BlogComment.new(form)
    blog_id = form.get('blog_id', -1)
    return redirect(url_for('.view', blog_id=blog_id))
예제 #6
0
def view(blog_id):
    print('inner view ({})'.format(blog_id))
    comments = BlogComment.find_all(blog_id=blog_id)
    blog = Blog.find(blog_id)
    return render_template("blog_view.html", blog=blog, comments=comments)
예제 #7
0
def add_comment():
    form = request.form
    c = BlogComment.new(form)
    return redirect(url_for('.view_blog', blog_id=c.blog_id))
예제 #8
0
def view_blog(blog_id):
    blog = Blog.find(blog_id)
    comments = BlogComment.find_all(blog_id=blog_id)
    return render_template('view_blog.html', blog=blog, comments=comments)