本文整理汇总了Python中models.Comment.find方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.find方法的具体用法?Python Comment.find怎么用?Python Comment.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_delete_comment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find [as 别名]
def api_delete_comment(id, request):
check_admin(request) # 检查权限
comment = yield from Comment.find(id) # 从数据库中取出评论
if comment is None:
raise APIResourceNotFoundError("Comment", "No such a Comment.")
yield from comment.remove() # 删除评论
return dict(id=id) # 返回被删评论的ID
示例2: api_delete_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find [as 别名]
def api_delete_comments(id, request):
check_admin(request)
c = yield from Comment.find(id)
if c is None:
raise APIResourceNotFoundError('Comment')
yield from c.remove()
return dict(id=id)
示例3: api_delete_comment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find [as 别名]
def api_delete_comment(id, request):
logging.info(id)
check_admin(request)
comment = yield from Comment.find(id)
if comment is None:
raise APIResourceNotFoundError('comment')
yield from comment.remove()
return dict(id=id)
示例4: api_delete_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find [as 别名]
def api_delete_comments(id, request):
#delete a comment
logging.info(id)
#管理员检查
check_admin(request)
#查询评论id是否有评论
c = yield from Comment.find(id)
if c is None:
raise APIResourceNotFoundError('Comment')
yield from c.remove()
示例5: api_delete_comments
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find [as 别名]
def api_delete_comments(id, request):
logging.info(id)
# 先检查是否是管理员操作,只有管理员才有删除评论权限
check_admin(request)
# 查询一下评论id是否有对应的评论
c = yield from Comment.find(id)
# 没有的话抛出错误
if c is None:
raise APIResourceNotFoundError('Comment')
# 有的话删除
yield from c.remove()
return dict(id=id)
示例6: delete_comment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find [as 别名]
def delete_comment(request, *, id):
check_admin(request)
comment = yield from Comment.find(id)
yield from comment.remove()
return dict(id=id)