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


Python httpexceptions.HTTPInternalServerError方法代码示例

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


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

示例1: __call__

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPInternalServerError [as 别名]
def __call__(self, info):
        """
        If a schema is present, replace value with output from schema.dump(..).
        """
        original_render = super().__call__(info)

        def schema_render(value, system):
            request = system.get('request')
            if (request is not None and isinstance(getattr(request, 'render_schema', None), Schema)):
# This doesn't catch errors...
                value, errors = request.render_schema.dump(value)
# This will catch errors
#                try:
#                    value, errors = request.render_schema.dump(value)
#                except Exception:
#                    errors = True

#                if errors:
#                    raise HTTPInternalServerError(body="Serialization failed.")

            return original_render(value, system)

        return schema_render 
开发者ID:ksanislo,项目名称:TitleDB,代码行数:25,代码来源:jsonhelper.py

示例2: please_fail

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPInternalServerError [as 别名]
def please_fail(request):
    raise exc.HTTPInternalServerError("internal error") 
开发者ID:instana,项目名称:python-sensor,代码行数:4,代码来源:app.py

示例3: _hello_endpoint

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPInternalServerError [as 别名]
def _hello_endpoint(request):
        helloid = int(request.matchdict["helloid"])
        if helloid == 500:
            raise exc.HTTPInternalServerError()
        return Response("Hello: " + str(helloid)) 
开发者ID:open-telemetry,项目名称:opentelemetry-python,代码行数:7,代码来源:pyramid_base_test.py


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