Beispiel #1
0
 def dispatch(self, environ, start_response):
     """The actual wsgi application. This is not implemented in `__call__`
     so that wsgi middlewares can be applied without losing a reference to
     the class.
     """
     with self.request_context(environ) as ctx:
         signals.send('request-started')
         try:
             try:
                 response = self.get_response(ctx.request)
             except HTTPException, e:
                 response = e
             except Exception, e:
                 signals.send('request-exception', error=e)
                 raise
             response = self.process_response(request, response)
Beispiel #2
0
    def test_disconnect(self):
        @signals.connect("foo-signal")
        def foo_handler1(bar):
            return bar

        @signals.connect("foo-signal")
        def foo_handler2(bar):
            return bar

        @signals.connect("foo-signal")
        def foo_handler3(bar):
            return bar

        assert signals.send("foo-signal", bar="BAR") == ["BAR", "BAR", "BAR"]
        signals.disconnect("foo-signal")
        assert signals.send("foo-signal", bar="FOO") == []
Beispiel #3
0
 def dispatch(self, environ, start_response):
     """The actual wsgi application. This is not implemented in `__call__`
     so that wsgi middlewares can be applied without losing a reference to
     the class.
     """
     with self.request_context(environ) as ctx:
         signals.send('request-started')
         try:
             try:
                 response = self.get_response(ctx.request)
             except HTTPException, e:
                 response = e
                 if e.code == 404 and self.debug and not len(pool.view_functions):
                     response = self.make_response(WELCOME_PAGE)
             except Exception, e:
                 signals.send('request-exception', error=e)
                 if self.debug:
                     raise
                 response = InternalServerError()
             response = self.process_response(request, response)
Beispiel #4
0
 def dispatch(self, environ, start_response):
     """The actual wsgi application. This is not implemented in `__call__`
     so that wsgi middlewares can be applied without losing a reference to
     the class.
     """
     with self.request_context(environ) as ctx:
         signals.send('request-started')
         try:
             try:
                 response = self.get_response(ctx.request)
             except HTTPException, e:
                 response = e
                 if e.code == 404 and self.debug and not len(
                         pool.view_functions):
                     response = self.make_response(WELCOME_PAGE)
             except Exception, e:
                 signals.send('request-exception', error=e)
                 if self.debug:
                     raise
                 response = InternalServerError()
             response = self.process_response(request, response)
Beispiel #5
0
    def test_connect(self):
        @signals.connect("foo-signal")
        def foo_handler1(bar):
            return 1, bar

        @signals.connect("foo-signal")
        def foo_handler2(bar):
            return 2, bar

        @signals.connect("foo-signal")
        def foo_handler3(bar):
            return 3, bar

        assert signals.send("foo-signal", bar="BAR") == [(1, "BAR"), (2, "BAR"), (3, "BAR")]
Beispiel #6
0
            signals.send('request-started')
            try:
                try:
                    response = self.get_response(ctx.request)
                except HTTPException, e:
                    response = e
                    if e.code == 404 and self.debug and not len(pool.view_functions):
                        response = self.make_response(WELCOME_PAGE)
                except Exception, e:
                    signals.send('request-exception', error=e)
                    if self.debug:
                        raise
                    response = InternalServerError()
                response = self.process_response(request, response)
            finally:
                signals.send('request-finished')
            return response(environ, start_response)

    def __call__(self, environ, start_response):
        return self.dispatch(environ, start_response)


def simple_server(host='127.0.0.1', port=8080, use_reloader=False):
    """Run a simple server for development purpose.

    :param host: host name
    :param post: port number
    :param use_reloader: whether to reload the server if any of the loaded
                         module changed.
    """
    from werkzeug import run_simple
Beispiel #7
0
            try:
                try:
                    response = self.get_response(ctx.request)
                except HTTPException, e:
                    response = e
                    if e.code == 404 and self.debug and not len(
                            pool.view_functions):
                        response = self.make_response(WELCOME_PAGE)
                except Exception, e:
                    signals.send('request-exception', error=e)
                    if self.debug:
                        raise
                    response = InternalServerError()
                response = self.process_response(request, response)
            finally:
                signals.send('request-finished')
            return response(environ, start_response)

    def __call__(self, environ, start_response):
        return self.dispatch(environ, start_response)


def simple_server(host='127.0.0.1', port=8080, use_reloader=False):
    """Run a simple server for development purpose.

    :param host: host name
    :param post: port number
    :param use_reloader: whether to reload the server if any of the loaded
                         module changed.
    """
    from werkzeug import run_simple