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)
def apiCommentDelete(id, request): checkAdmin(request) c = yield from Comment.find(id) if c is None: raise APIResourceNotFoundError('评论不存在') yield from c.remove() return dict(id=id)
def find_model(model, id): if model == 'blog': blog = yield from Blog.find(id) return blog if model == 'user': user = yield from User.find(id) return user if model == 'comment': comment = yield from Comment.find(id) return comment
def api_delete_comments(id, request): #校验当前用户权限: check_admin(request) #数据库Comment表中查询指定评论信息: c = yield from Comment.find(id) #查询无结果则抛出异常: if c is None: raise APIResourceNotFoundError('Comment') #将Comment信息从数据库删除: yield from c.remove() return dict(id=id)