当前位置: 首页>>代码示例>>Python>>正文


Python apis.APIPermissionError方法代码示例

本文整理汇总了Python中apis.APIPermissionError方法的典型用法代码示例。如果您正苦于以下问题:Python apis.APIPermissionError方法的具体用法?Python apis.APIPermissionError怎么用?Python apis.APIPermissionError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apis的用法示例。


在下文中一共展示了apis.APIPermissionError方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: api_create_comment

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
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????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:21,代码来源:handlers.py

示例2: check_admin

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def check_admin(request):
	if request.__user__ is None or not request.__user__.admin:
		raise APIPermissionError()
# ?? 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:6,代码来源:handlers.py

示例3: api_create_comments

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def api_create_comments(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 = 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 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:14,代码来源:handlers.py

示例4: check_admin

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def check_admin(request):
    if request.__user__ is None or not request.__user__.admin:
        raise APIPermissionError() 
开发者ID:tianzhenyun,项目名称:python-awesome-web,代码行数:5,代码来源:handlers.py

示例5: api_create_blog_comments

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def api_create_blog_comments(request, *, id, content):
    '''create blog comments'''
    if not request.__user__:
        raise APIPermissionError('please login first.')

    if not content or not content.strip():
        raise APIValueError('content', 'content can not be empty.')

    blog = yield from Blog.find(id)
    if blog is None:
        raise APIResourceNotFoundError('blog', 'can not find blog, id :{}'.format(id))

    comment = Comment(blog_id = id, user_id= request.__user__.id, user_name = request.__user__.name, user_image = request.__user__.image, content = content.strip() )
    yield from comment.save()
    return comment 
开发者ID:tianzhenyun,项目名称:python-awesome-web,代码行数:17,代码来源:handlers.py

示例6: check_admin

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def check_admin():
    user = ctx.request.user
    if user and user.admin:
        return
    raise APIPermissionError('No permission.') 
开发者ID:tzshlyt,项目名称:python-webapp-blog,代码行数:7,代码来源:urls.py

示例7: api_create_blog_comment

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def api_create_blog_comment(blog_id):
    user = ctx.request.user
    if user is None:
        raise APIPermissionError('Need signin.')
    blog = Blog.get(blog_id)
    if blog is None:
        raise APIResourceNotFoundError('Blog')
    content = ctx.request.input(content='').content.strip()
    if not content:
        raise APIValueError('content')
    c = Comment(blog_id=blog_id, user_id=user.id,
                user_name=user.name, user_image=user.image, content=content)
    c.insert()
    return dict(comment=c) 
开发者ID:tzshlyt,项目名称:python-webapp-blog,代码行数:16,代码来源:urls.py

示例8: check_admin

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def check_admin(request):
    if request.__user__ is None or not request.__user__.admin:
        raise APIPermissionError()


# ?????day11????
# ??????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:9,代码来源:handlers.py

示例9: check_admin

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def check_admin(request):
	if request.__user__ is None or not request.__user__.admin:
		raise APIPermissionError() 
开发者ID:TsangTen,项目名称:awesome-webapp,代码行数:5,代码来源:handlers.py

示例10: api_create_comment

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
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', 'empty!')
	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 
开发者ID:TsangTen,项目名称:awesome-webapp,代码行数:14,代码来源:handlers.py

示例11: check_admin

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
def check_admin(request):
    '''
    ??????????????user???admin??
    '''
    if request.__user__ is None or not request.__user__.admin:
        raise APIPermissionError() 
开发者ID:chenpengcong,项目名称:python3-webapp,代码行数:8,代码来源:handlers.py

示例12: api_create_comment

# 需要导入模块: import apis [as 别名]
# 或者: from apis import APIPermissionError [as 别名]
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 
开发者ID:chenpengcong,项目名称:python3-webapp,代码行数:17,代码来源:handlers.py


注:本文中的apis.APIPermissionError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。