handlers.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:python3-webapp 作者: chenpengcong 项目源码 文件源码
def api_create_comment(id, request, *, content):
    '''
    ????, ????blog.html.
    '''
    user = request.__user__
    if user is None:
        raise APIPermissionError('Please signin first.')
    if not content or not content.strip():
        raise APIValueError('content')
    blog = await Blog.find(id)
    if blog is None:
        raise APIResourceNotFoundError('Blog')
    comment = Comment(blog_id = blog.id, user_id = user.id, user_name = user.name, user_image = user.image, content = content.strip())
    await comment.save()
    return comment
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号