handlers.py 文件源码

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

项目:Preeminent 作者: ReedSun 项目源码 文件源码
def api_create_comment(id, request, *, content):
    user = request.__user__
    # ????
    if user is None:
        raise APIPermissionError('Please signin first.')
    # ??????????
    if not content or not content.strip():
        raise APIValueError('content')
    # ????????
    blog = yield from 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())
    yield from comment.save()  # ?????????
    return comment  # ????

# day14??
# API?????
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号