當前位置: 首頁>>代碼示例>>Python>>正文


Python apis.APIResourceNotFoundError方法代碼示例

本文整理匯總了Python中apis.APIResourceNotFoundError方法的典型用法代碼示例。如果您正苦於以下問題:Python apis.APIResourceNotFoundError方法的具體用法?Python apis.APIResourceNotFoundError怎麽用?Python apis.APIResourceNotFoundError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apis的用法示例。


在下文中一共展示了apis.APIResourceNotFoundError方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: api_update_blog

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_update_blog(blog_id):
    check_admin()
    i = ctx.request.input(name='', summary='', content='')
    name = i.name.strip()
    summary = i.summary.strip()
    content = i.content.strip()
    if not name:
        raise APIValueError('name', 'name cannot be empty.')
    if not summary:
        raise APIValueError('summary', 'summary cannot be empty.')
    if not content:
        raise APIValueError('content', 'content cannot be empty.')
    blog = Blog.get(blog_id)
    if blog is None:
        raise APIResourceNotFoundError('Blog')
    blog.name = name
    blog.summary = summary
    blog.content = content
    blog.update()
    return blog 
開發者ID:tzshlyt,項目名稱:python-webapp-blog,代碼行數:22,代碼來源:urls.py

示例2: api_create_comment

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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

示例3: api_create_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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: api_delete_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_delete_comments(id,request):
	check_admin(request)
	c = await Comment.find(id)
	if c is None:
		raise APIResourceNotFoundError('Comment')
	await c.remove()
	return dict(id=id) 
開發者ID:syusonn,項目名稱:awesome-python3-webapp,代碼行數:9,代碼來源:handlers.py

示例5: api_create_blog_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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: api_delete_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_delete_comments(request, *, comment_id):
    '''delete comment.'''
    check_admin(request)
    comment = yield from Comment.find(comment_id)
    if comment is None:
        raise APIResourceNotFoundError('Comment', 'can not find comment, comment id: {}'.format(comment_id))
    yield from comment.remove()
    return comment 
開發者ID:tianzhenyun,項目名稱:python-awesome-web,代碼行數:10,代碼來源:handlers.py

示例7: api_get_blog

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_get_blog(blog_id):
    blog = Blog.get(blog_id)
    if blog:
        return blog
    raise APIResourceNotFoundError('Blog') 
開發者ID:tzshlyt,項目名稱:python-webapp-blog,代碼行數:7,代碼來源:urls.py

示例8: api_delete_blog

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_delete_blog(blog_id):
    check_admin()
    blog = Blog.get(blog_id)
    if blog is None:
        raise APIResourceNotFoundError('Blog')
    blog.delete()
    return dict(id=blog_id) 
開發者ID:tzshlyt,項目名稱:python-webapp-blog,代碼行數:9,代碼來源:urls.py

示例9: api_create_blog_comment

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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

示例10: api_delete_comment

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_delete_comment(comment_id):
    check_admin()
    comment = Comment.get(comment_id)
    if comment is None:
        raise APIResourceNotFoundError('Comment')
    comment.delete()
    return dict(id=comment_id) 
開發者ID:tzshlyt,項目名稱:python-webapp-blog,代碼行數:9,代碼來源:urls.py

示例11: api_delete_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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)  # ????????id

# day14??
# API:???? 
開發者ID:ReedSun,項目名稱:Preeminent,代碼行數:12,代碼來源:handlers.py

示例12: api_create_comment

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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 
開發者ID:xsingHu,項目名稱:xs-python-architecture,代碼行數:14,代碼來源:handlers.py

示例13: api_delete_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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) 
開發者ID:xsingHu,項目名稱:xs-python-architecture,代碼行數:9,代碼來源:handlers.py

示例14: api_create_comment

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [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

示例15: api_delete_comments

# 需要導入模塊: import apis [as 別名]
# 或者: from apis import APIResourceNotFoundError [as 別名]
def api_delete_comments(id, request):
	check_admin(request)
	c = await Comment.find(id)
	if c is None:
		raise APIResourceNotFoundError('Comment', 'Not Found!')
	await c.remove()
	return dict(id=id) 
開發者ID:TsangTen,項目名稱:awesome-webapp,代碼行數:9,代碼來源:handlers.py


注:本文中的apis.APIResourceNotFoundError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。