当前位置: 首页>>代码示例>>Python>>正文


Python validate.validator方法代码示例

本文整理汇总了Python中wsgiref.validate.validator方法的典型用法代码示例。如果您正苦于以下问题:Python validate.validator方法的具体用法?Python validate.validator怎么用?Python validate.validator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wsgiref.validate的用法示例。


在下文中一共展示了validate.validator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_app

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def get_app(self, app=None):
        """Obtain a new (decorated) WSGI app to hook into the origin server."""
        if app is None:
            app = cherrypy.tree

        if self.validate:
            try:
                from wsgiref import validate
            except ImportError:
                warnings.warn(
                    'Error importing wsgiref. The validator will not run.')
            else:
                # wraps the app in the validator
                app = validate.validator(app)

        return app 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:18,代码来源:helper.py

示例2: get_app

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
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
        return WSGIContainer(validator(WSGIApplication([
            ("/", HelloHandler),
            ("/path/(.*)", PathQuotingHandler),
            ("/typecheck", TypeCheckHandler),
        ]))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:wsgi_test.py

示例3: get_app

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
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),
                ])))) 
开发者ID:tp4a,项目名称:teleport,代码行数:22,代码来源:wsgi_test.py

示例4: wrap_web_tests_application

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        def class_factory():
            class WSGIApplicationWrappedTest(cls):  # type: ignore
                def setUp(self):
                    self.warning_catcher = ignore_deprecation()
                    self.warning_catcher.__enter__()
                    super(WSGIApplicationWrappedTest, self).setUp()

                def tearDown(self):
                    super(WSGIApplicationWrappedTest, self).tearDown()
                    self.warning_catcher.__exit__(None, None, None)

                def get_app(self):
                    self.app = WSGIApplication(self.get_handlers(),
                                               **self.get_app_kwargs())
                    return WSGIContainer(validator(self.app))
        result["WSGIApplication_" + cls.__name__] = class_factory()
    return result 
开发者ID:tp4a,项目名称:teleport,代码行数:22,代码来源:wsgi_test.py

示例5: test_bytes_validation

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def test_bytes_validation(self):
        def app(e, s):
            s("200 OK", [
                ("Content-Type", "text/plain; charset=utf-8"),
                ("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
                ])
            return [b"data"]
        out, err = run_amock(validator(app))
        self.assertTrue(err.endswith('"GET / HTTP/1.0" 200 4\n'))
        ver = sys.version.split()[0].encode('ascii')
        py  = python_implementation().encode('ascii')
        pyver = py + b"/" + ver
        self.assertEqual(
                b"HTTP/1.0 200 OK\r\n"
                b"Server: WSGIServer/0.2 "+ pyver + b"\r\n"
                b"Content-Type: text/plain; charset=utf-8\r\n"
                b"Date: Wed, 24 Dec 2008 13:29:32 GMT\r\n"
                b"\r\n"
                b"data",
                out) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_wsgiref.py

示例6: get_app

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
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
        return WSGIContainer(validator(WSGIApplication([
                        ("/", HelloHandler),
                        ("/path/(.*)", PathQuotingHandler),
                        ("/typecheck", TypeCheckHandler),
                        ]))) 
开发者ID:omererdem,项目名称:honeything,代码行数:20,代码来源:wsgi_test.py

示例7: test_cp1252_url

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def test_cp1252_url(self):
        def app(e, s):
            s("200 OK", [
                ("Content-Type", "text/plain"),
                ("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
                ])
            # PEP3333 says environ variables are decoded as latin1.
            # Encode as latin1 to get original bytes
            return [e["PATH_INFO"].encode("latin1")]

        out, err = run_amock(
            validator(app), data=b"GET /\x80%80 HTTP/1.0")
        self.assertEqual(
            [
                b"HTTP/1.0 200 OK",
                mock.ANY,
                b"Content-Type: text/plain",
                b"Date: Wed, 24 Dec 2008 13:29:32 GMT",
                b"",
                b"/\x80\x80",
            ],
            out.splitlines()) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:24,代码来源:test_wsgiref.py

示例8: roulette_server_3

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def roulette_server_3(count: int = 1) -> None:
    from wsgiref.simple_server import make_server
    from wsgiref.validate import validator

    wheel = American(seed=1)
    roulette = Roulette(wheel)
    debug = validator(roulette)
    httpd = make_server("", 8080, debug)
    if count is None:
        httpd.serve_forever()
    else:
        for c in range(count):
            httpd.handle_request()


# Client 
开发者ID:PacktPublishing,项目名称:Mastering-Object-Oriented-Python-Second-Edition,代码行数:18,代码来源:ch13_e1_ex3.py

示例9: roulette_server_4

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def roulette_server_4(count: int = 1):
    from wsgiref.simple_server import make_server
    from wsgiref.validate import validator

    wheel = American()
    roulette = Roulette(wheel)
    debug = validator(roulette)
    httpd = make_server("", 8080, debug)
    if count is None:
        httpd.serve_forever()
    else:
        for c in range(count):
            httpd.handle_request()


# Client 
开发者ID:PacktPublishing,项目名称:Mastering-Object-Oriented-Python-Second-Edition,代码行数:18,代码来源:ch13_e1_ex4.py

示例10: auth_server

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def auth_server(count: int = 1) -> None:
    from wsgiref.simple_server import make_server
    from wsgiref.validate import validator

    secure_app = Some_App()
    authenticated_app = Authenticate(users, secure_app)
    debug = validator(authenticated_app)
    httpd = make_server("", 8080, debug)
    if count is None:
        httpd.serve_forever()
    else:
        for c in range(count):
            httpd.handle_request()


# Demo 
开发者ID:PacktPublishing,项目名称:Mastering-Object-Oriented-Python-Second-Edition,代码行数:18,代码来源:ch13_e1_ex4.py

示例11: get_app

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def get_app(self, app=None):
        """Obtain a new (decorated) WSGI app to hook into the origin server."""
        if app is None:
            app = cherrypy.tree
        
        if self.conquer:
            try:
                import wsgiconq
            except ImportError:
                warnings.warn("Error importing wsgiconq. pyconquer will not run.")
            else:
                app = wsgiconq.WSGILogger(app, c_calls=True)
        
        if self.validate:
            try:
                from wsgiref import validate
            except ImportError:
                warnings.warn("Error importing wsgiref. The validator will not run.")
            else:
                #wraps the app in the validator
                app = validate.validator(app)
        
        return app 
开发者ID:binhex,项目名称:moviegrabber,代码行数:25,代码来源:helper.py

示例12: wrap_web_tests_application

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIApplicationWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIApplication_" + cls.__name__] = WSGIApplicationWrappedTest
    return result 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:wsgi_test.py

示例13: wrap_web_tests_adapter

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
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 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:wsgi_test.py

示例14: test_validated_hello

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def test_validated_hello(self):
        out, err = run_amock(validator(hello_app))
        # the middleware doesn't support len(), so content-length isn't there
        self.check_hello(out, has_length=False) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_wsgiref.py

示例15: test_simple_validation_error

# 需要导入模块: from wsgiref import validate [as 别名]
# 或者: from wsgiref.validate import validator [as 别名]
def test_simple_validation_error(self):
        def bad_app(environ,start_response):
            start_response("200 OK", ('Content-Type','text/plain'))
            return ["Hello, world!"]
        out, err = run_amock(validator(bad_app))
        self.assertTrue(out.endswith(
            "A server error occurred.  Please contact the administrator."
        ))
        self.assertEqual(
            err.splitlines()[-2],
            "AssertionError: Headers (('Content-Type', 'text/plain')) must"
            " be of type list: <type 'tuple'>"
        ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_wsgiref.py


注:本文中的wsgiref.validate.validator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。