本文整理匯總了Python中pyramid.httpexceptions.HTTPNotFound方法的典型用法代碼示例。如果您正苦於以下問題:Python httpexceptions.HTTPNotFound方法的具體用法?Python httpexceptions.HTTPNotFound怎麽用?Python httpexceptions.HTTPNotFound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyramid.httpexceptions
的用法示例。
在下文中一共展示了httpexceptions.HTTPNotFound方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: api_hazardcategory
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def api_hazardcategory(request):
hazard_type = request.matchdict["hazard_type"]
hazard_level = request.matchdict["hazard_level"]
GoogleAnalytics().hit(request, "hazardcategory-hazard_type-hazard_level")
try:
hazard_category = (
request.dbsession.query(HazardCategory)
.join(HazardType)
.join(HazardLevel)
.filter(HazardType.mnemonic == hazard_type)
.filter(HazardLevel.mnemonic == hazard_level)
.one()
)
except:
raise HTTPNotFound()
return {"hazard_category": hazard_category}
示例2: ops_document_kindcodes
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def ops_document_kindcodes(patent):
error_msg_access = 'No bibliographic information for document={0}'.format(patent)
log.info('Retrieving kindcodes for document {document}'.format(document=patent))
documents = ops_biblio_documents(patent)
kindcodes = []
for document in documents:
# TODO: check whether a single occurrance of "not found" should really raise this exception
if document.has_key('@status') and document['@status'] == 'not found':
error = HTTPNotFound(error_msg_access)
raise error
kindcode = document['@kind']
kindcodes.append(kindcode)
return kindcodes
示例3: favicon_view
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def favicon_view(request):
"""
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/assets.html#registering-a-view-callable-to-serve-a-static-asset
"""
icon = resource_filename('kotori.frontend', 'static/favicon.ico')
if os.path.isfile(icon):
return FileResponse(icon, request=request)
else:
return HTTPNotFound()
示例4: details
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def details(request: Request):
package_name = request.matchdict.get('package_name')
if not package_name:
raise x.HTTPNotFound()
return {
'package_name': package_name
}
# /project/{package_name}/releases
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:13,代碼來源:packages_controller.py
示例5: releases
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def releases(request: Request):
package_name = request.matchdict.get('package_name')
if not package_name:
raise x.HTTPNotFound()
return {
'package_name': package_name,
'releases': []
}
# /project/{package_name}/releases/{release_version}
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:14,代碼來源:packages_controller.py
示例6: release_version
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def release_version(request: Request):
package_name = request.matchdict.get('package_name')
release_ver = request.matchdict.get('release_version')
if not package_name:
raise x.HTTPNotFound()
return {
'package_name': package_name,
'release_version': release_ver,
'releases': []
}
# /{num}
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:16,代碼來源:packages_controller.py
示例7: popular
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def popular(request: Request):
num = int(request.matchdict.get('num', -1))
if not (1 <= num or num <= 10):
raise x.HTTPNotFound()
return {
'package_name': "The {}th popular package".format(num)
}
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:10,代碼來源:packages_controller.py
示例8: cms_page
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def cms_page(request: Request):
subpath = request.matchdict.get('subpath')
suburl = '/'.join(subpath)
page = fake_db.get(suburl)
if not page:
raise HTTPNotFound()
return page
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:11,代碼來源:cms_controller.py
示例9: popular
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def popular(request: Request):
vm = PopularPackageViewModel(request)
if not (1 <= vm.num or vm.num <= 10):
raise x.HTTPNotFound()
return vm.to_dict()
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:8,代碼來源:packages_controller.py
示例10: cms_page
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def cms_page(request: Request):
vm = PageViewModel(request)
if not vm.page:
raise HTTPNotFound()
return vm.to_dict()
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:8,代碼來源:cms_controller.py
示例11: details
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def details(request: Request):
vm = PackageDetailsViewModel(request)
if not vm.package:
raise x.HTTPNotFound()
return vm.to_dict()
# /{num}
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:11,代碼來源:packages_controller.py
示例12: details
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def details(request: Request):
package_name = request.matchdict.get('package_name')
package = package_service.find_package_by_name(package_name)
if not package:
raise x.HTTPNotFound()
latest_version = '0.0.0'
latest_release = None
if package.releases:
latest_release = package.releases[0]
latest_version = '{}.{}.{}'.format(
latest_release.major_ver,
latest_release.minor_ver,
latest_release.build_ver
)
return {
'package': package,
'latest_version': latest_version,
'latest_release': latest_release,
'release_version': latest_version,
'maintainers': [],
'is_latest': True,
'user_id': cookie_auth.get_user_id_via_auth_cookie(request)
}
# /{num}
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:31,代碼來源:packages_controller.py
示例13: popular
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def popular(request: Request):
num = int(request.matchdict.get('num', -1))
if not (1 <= num or num <= 10):
raise x.HTTPNotFound()
return {
'package_name': "The {}th popular package".format(num),
'user_id': cookie_auth.get_user_id_via_auth_cookie(request)
}
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:11,代碼來源:packages_controller.py
示例14: cms_page
# 需要導入模塊: from pyramid import httpexceptions [as 別名]
# 或者: from pyramid.httpexceptions import HTTPNotFound [as 別名]
def cms_page(request: Request):
subpath = request.matchdict.get('subpath')
suburl = '/'.join(subpath)
page = fake_db.get(suburl)
if not page:
raise HTTPNotFound()
page['user_id'] = str(cookie_auth.get_user_id_via_auth_cookie(request))
return page
開發者ID:talkpython,項目名稱:data-driven-web-apps-with-pyramid-and-sqlalchemy,代碼行數:12,代碼來源:cms_controller.py