Python tornado.wsgi.WSGIAdapter() Examples

The following are 10 code examples of tornado.wsgi.WSGIAdapter(). 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.wsgi , or try the search function .
Example #1
Source File: wsgi_test.py    From teleport with Apache License 2.0 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # another thread instead of using our own WSGIContainer, but this
        # fits better in our async testing framework and the wsgiref
        # validator should keep us honest
        with ignore_deprecation():
            return WSGIContainer(validator(WSGIAdapter(
                Application([
                    ("/", HelloHandler),
                    ("/path/(.*)", PathQuotingHandler),
                    ("/typecheck", TypeCheckHandler),
                ])))) 
Example #2
Source File: wsgi_test.py    From pySINDy with MIT License 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # another thread instead of using our own WSGIContainer, but this
        # fits better in our async testing framework and the wsgiref
        # validator should keep us honest
        with ignore_deprecation():
            return WSGIContainer(validator(WSGIAdapter(
                Application([
                    ("/", HelloHandler),
                    ("/path/(.*)", PathQuotingHandler),
                    ("/typecheck", TypeCheckHandler),
                ])))) 
Example #3
Source File: register.py    From itchatmp with MIT License 6 votes vote down vote up
def run(self, isWsgi=False, debug=True, port=80):
    self.isWsgi = isWsgi
    self.debug = debug
    if debug:
        set_logging(loggingLevel=logging.DEBUG)
    MainHandler = construct_handler(self, isWsgi)
    app = tornado.web.Application(
        [('/', MainHandler)], debug=debug)
    logger.info('itchatmp started!%s' % (
        ' press Ctrl+C to exit.' if debug else ''))
    if isWsgi:
        return WSGIAdapter(app)
    else:
        port = int(port)
        env_test(port)
        app.listen(port)
        try:
            self.ioLoop.start()
        except:
            logger.info('Bye~')
            self.ioLoop.stop() 
Example #4
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def wrap_web_tests_adapter():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIAdapterWrappedTest(cls):
            def get_app(self):
                self.app = Application(self.get_handlers(),
                                       **self.get_app_kwargs())
                return WSGIContainer(validator(WSGIAdapter(self.app)))
        result["WSGIAdapter_" + cls.__name__] = WSGIAdapterWrappedTest
    return result 
Example #5
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def wrap_web_tests_adapter():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIAdapterWrappedTest(cls):
            def get_app(self):
                self.app = Application(self.get_handlers(),
                                       **self.get_app_kwargs())
                return WSGIContainer(validator(WSGIAdapter(self.app)))
        result["WSGIAdapter_" + cls.__name__] = WSGIAdapterWrappedTest
    return result 
Example #6
Source File: wsgi_test.py    From teleport with Apache License 2.0 5 votes vote down vote up
def get_app(self):
        with ignore_deprecation():
            return WSGIContainer(validator(WSGIAdapter(Application(self.get_handlers())))) 
Example #7
Source File: wsgi_test.py    From teleport with Apache License 2.0 5 votes vote down vote up
def wrap_web_tests_adapter():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIAdapterWrappedTest(cls):  # type: ignore
            def get_app(self):
                self.app = Application(self.get_handlers(),
                                       **self.get_app_kwargs())
                with ignore_deprecation():
                    return WSGIContainer(validator(WSGIAdapter(self.app)))
        result["WSGIAdapter_" + cls.__name__] = WSGIAdapterWrappedTest
    return result 
Example #8
Source File: wsgi_test.py    From pySINDy with MIT License 5 votes vote down vote up
def get_app(self):
        with ignore_deprecation():
            return WSGIContainer(validator(WSGIAdapter(Application(self.get_handlers())))) 
Example #9
Source File: wsgi_test.py    From pySINDy with MIT License 5 votes vote down vote up
def wrap_web_tests_adapter():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIAdapterWrappedTest(cls):  # type: ignore
            def get_app(self):
                self.app = Application(self.get_handlers(),
                                       **self.get_app_kwargs())
                with ignore_deprecation():
                    return WSGIContainer(validator(WSGIAdapter(self.app)))
        result["WSGIAdapter_" + cls.__name__] = WSGIAdapterWrappedTest
    return result 
Example #10
Source File: wsgi_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def wrap_web_tests_adapter():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIAdapterWrappedTest(cls):
            def get_app(self):
                self.app = Application(self.get_handlers(),
                                       **self.get_app_kwargs())
                return WSGIContainer(validator(WSGIAdapter(self.app)))
        result["WSGIAdapter_" + cls.__name__] = WSGIAdapterWrappedTest
    return result