本文整理汇总了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
示例2: please_fail
# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPInternalServerError [as 别名]
def please_fail(request):
raise exc.HTTPInternalServerError("internal error")
示例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))