Python tornado.web.ErrorHandler() Examples

The following are 9 code examples of tornado.web.ErrorHandler(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tornado.web , or try the search function .
Example #1
Source File: web_test.py    From tornado-zh with MIT License 5 votes vote down vote up
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))] 
Example #2
Source File: web_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def get_app_kwargs(self):
        return dict(default_handler_class=ErrorHandler,
                    default_handler_args=dict(status_code=403)) 
Example #3
Source File: web_test.py    From tornado-zh with MIT License 5 votes vote down vote up
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))] 
Example #4
Source File: web_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def get_app_kwargs(self):
        return dict(default_handler_class=ErrorHandler,
                    default_handler_args=dict(status_code=403)) 
Example #5
Source File: web_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
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))] 
Example #6
Source File: web_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
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))] 
Example #7
Source File: web_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
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))] 
Example #8
Source File: web_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def get_app_kwargs(self):
        return dict(default_handler_class=ErrorHandler,
                    default_handler_args=dict(status_code=403)) 
Example #9
Source File: httpmodule.py    From torngas with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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