本文整理汇总了Python中tornado.web.ErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:Python web.ErrorHandler方法的具体用法?Python web.ErrorHandler怎么用?Python web.ErrorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web
的用法示例。
在下文中一共展示了web.ErrorHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_handlers
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import ErrorHandler [as 别名]
def get_handlers(self):
# note that if the handlers list is empty we get the default_host
# redirect fallback instead of a 404, so test with both an
# explicitly defined error handler and an implicit 404.
return [('/error', ErrorHandler, dict(status_code=417))]
示例2: get_app_kwargs
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import ErrorHandler [as 别名]
def get_app_kwargs(self):
return dict(default_handler_class=ErrorHandler,
default_handler_args=dict(status_code=403))
示例3: _execute_module
# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import ErrorHandler [as 别名]
def _execute_module(self, handler, clear, module, method, name=None, **kwargs):
try:
def run_method_():
if method.__name__ == "begin_response":
return method(handler, clear, kwargs.pop("chunk", None))
elif method.__name__ == "begin_render":
return method(handler, clear, **kwargs)
elif method.__name__ == 'begin_request':
return method(handler, clear)
elif method.__name__ == 'complete_response':
return method(handler, clear)
if name:
if hasattr(handler, 'pattern__'):
patt = handler.pattern__
if name == patt:
url_spec = self.named_handlers.get(name, None)
if url_spec:
if isinstance(handler, url_spec.handler_class):
return run_method_()
elif handler.request.re_match_table[name]:
return run_method_()
else:
pattern__ = getattr(handler, 'pattern__', None)
def check_(key):
non_execute = self.non_executes_modules.get(key, [])
if non_execute:
for n in non_execute:
if isinstance(module, n):
return True
if pattern__ in self.non_executes_modules:
if check_(handler.pattern__): return
if hasattr(handler.request, 're_match_table') and handler.request.re_match_table:
for key, match in handler.request.re_match_table.items():
if match:
if check_(key): return
if not isinstance(handler, ErrorHandler):
return run_method_()
except BaseException, ex:
raise