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


Python httpexceptions.HTTPNotFound方法代码示例

本文整理汇总了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} 
开发者ID:GFDRR,项目名称:thinkhazard,代码行数:20,代码来源:api.py

示例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 
开发者ID:ip-tools,项目名称:patzilla,代码行数:21,代码来源:api.py

示例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() 
开发者ID:daq-tools,项目名称:kotori,代码行数:11,代码来源:views.py

示例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


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