• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wsgi.WsgiApplication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spyne.server.wsgi.WsgiApplication的典型用法代码示例。如果您正苦于以下问题:Python WsgiApplication类的具体用法?Python WsgiApplication怎么用?Python WsgiApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_nested_flatten_with_multiple_values_2

    def test_nested_flatten_with_multiple_values_2(self):
        class CM(ComplexModel):
            i = Integer
            s = String

        class CCM(ComplexModel):
            c = CM.customize(max_occurs=2)
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(CCM, _returns=String)
            def some_call(ccm):
                return repr(ccm)

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': 'ccm_i=1&ccm_s=s&ccm_c_i=3&ccm_c_s=cs',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
        }, 'some-content-type')

        ctx, = server.generate_contexts(initial_ctx)

        try:
            server.get_in_object(ctx)
        except:
            pass
        else:
            raise Exception("Must fail with: Exception: HttpRpc deserializer "
                        "does not support non-primitives with max_occurs > 1")
开发者ID:anthonyrisinger,项目名称:spyne,代码行数:33,代码来源:test_http.py


示例2: __get_ctx

    def __get_ctx(self, mn, qs):
        server = WsgiApplication(self.application)
        ctx = WsgiMethodContext(
            server,
            {"QUERY_STRING": qs, "PATH_INFO": "/%s" % mn, "REQUEST_METHOD": "GET", "SERVER_NAME": "localhost"},
            "some-content-type",
        )

        ctx, = server.generate_contexts(ctx)
        server.get_in_object(ctx)

        return ctx
开发者ID:rahims,项目名称:spyne,代码行数:12,代码来源:test_soft_validation.py


示例3: __get_ctx

    def __get_ctx(self, mn, qs):
        server = WsgiApplication(self.application)
        ctx = WsgiMethodContext(server, {
            'QUERY_STRING': qs,
            'PATH_INFO': '/%s' % mn,
            'REQUEST_METHOD': "GET",
        }, 'some-content-type')

        ctx, = server.generate_contexts(ctx)
        server.get_in_object(ctx)

        return ctx
开发者ID:anthonyrisinger,项目名称:spyne,代码行数:12,代码来源:test_soft_validation.py


示例4: _test

def _test(services, qs, validator="soft", strict_arrays=False):
    app = Application(
        services, "tns", in_protocol=HttpRpc(validator=validator, strict_arrays=strict_arrays), out_protocol=HttpRpc()
    )
    server = WsgiApplication(app)

    initial_ctx = WsgiMethodContext(
        server,
        {"QUERY_STRING": qs, "PATH_INFO": "/some_call", "REQUEST_METHOD": "GET", "SERVER_NAME": "localhost"},
        "some-content-type",
    )

    ctx, = server.generate_contexts(initial_ctx)

    server.get_in_object(ctx)
    if ctx.in_error is not None:
        raise ctx.in_error

    server.get_out_object(ctx)
    if ctx.out_error is not None:
        raise ctx.out_error

    server.get_out_string(ctx)

    return ctx
开发者ID:akash0675,项目名称:spyne,代码行数:25,代码来源:test_http.py


示例5: _test

def _test(services, qs, validator='soft'):
    app = Application(services, 'tns', in_protocol=HttpRpc(validator=validator),
                                       out_protocol=HttpRpc())
    server = WsgiApplication(app)

    initial_ctx = WsgiMethodContext(server, {
        'QUERY_STRING': qs,
        'PATH_INFO': '/some_call',
        'REQUEST_METHOD': 'GET',
        'SERVER_NAME': "localhost",
    }, 'some-content-type')

    ctx, = server.generate_contexts(initial_ctx)

    server.get_in_object(ctx)
    if ctx.in_error is not None:
        raise ctx.in_error

    server.get_out_object(ctx)
    if ctx.out_error is not None:
        raise ctx.out_error

    server.get_out_string(ctx)

    return ctx
开发者ID:mescam,项目名称:spyne,代码行数:25,代码来源:test_http.py


示例6: test_complex

    def test_complex(self):
        class CM(ComplexModel):
            i = Integer
            s = String

        class CCM(ComplexModel):
            c = CM
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(CCM, _returns=CCM)
            def some_call(ccm):
                return CCM(c=ccm.c, i=ccm.i, s=ccm.s)

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)
        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
        }, 'some-content-type')
        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)
开发者ID:anthonyrisinger,项目名称:spyne,代码行数:26,代码来源:test_http.py


示例7: test_primitive_only

    def test_primitive_only(self):
        class SomeComplexModel(ComplexModel):
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(SomeComplexModel, _returns=SomeComplexModel)
            def some_call(scm):
                return SomeComplexModel(i=5, s='5x')

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
        }, 'some-content-type')
        ctx, = server.generate_contexts(initial_ctx)

        server.get_in_object(ctx)
        server.get_out_object(ctx)
        try:
            server.get_out_string(ctx)
        except:
            pass
        else:
            raise Exception("Must fail with: HttpRpc does not support complex "
                "return types.")
开发者ID:anthonyrisinger,项目名称:spyne,代码行数:29,代码来源:test_http.py


示例8: test_multiple_return

    def test_multiple_return(self):
        class SomeNotSoComplexModel(ComplexModel):
            s = String

        class SomeService(ServiceBase):
            @srpc(_returns=[Integer, String])
            def some_call():
                return 1, 's'

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
            'QUERY_STRING': '?s=a',
            'REQUEST_METHOD': 'GET',
        }, 'some-content-type')

        try:
            ctx, = server.generate_contexts(initial_ctx)
            server.get_in_object(ctx)
            server.get_out_object(ctx)
            server.get_out_string(ctx)
        except ValueError:
            pass
        else:
            raise Exception("Must fail with: HttpRpc does not support complex "
                "return types.")
开发者ID:anthonyrisinger,项目名称:spyne,代码行数:29,代码来源:test_http.py


示例9: test_simple

    def test_simple(self):
        class SomeService(ServiceBase):
            @srpc(String, _returns=String)
            def some_call(s):
                return s

        app = Application([SomeService], 'tns',
                                            in_protocol=HttpRpc(hier_delim='_'),
                                            out_protocol=HtmlMicroFormat())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': 's=s',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
            'SERVER_NAME': 'localhost',
        }, 'some-content-type')

        ctx, = server.generate_contexts(initial_ctx)
        assert ctx.in_error is None

        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)

        assert ''.join(ctx.out_string) == '<div class="some_callResponse"><div class="some_callResult">s</div></div>'
开发者ID:lanwan,项目名称:spyne,代码行数:26,代码来源:test_html_microformat.py


示例10: test_multiple_return

    def test_multiple_return(self):
        class SomeNotSoComplexModel(ComplexModel):
            s = String

        class SomeService(ServiceBase):
            @srpc(_returns=[Integer, String])
            def some_call():
                return 1, 's'

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HtmlMicroFormat())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
            'SERVER_NAME': 'localhost',
        }, 'some-content-type')

        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)

        assert ''.join(ctx.out_string) == '<div class="some_callResponse"><div class="some_callResult0">1</div><div class="some_callResult1">s</div></div>'
开发者ID:lanwan,项目名称:spyne,代码行数:25,代码来源:test_html_microformat.py


示例11: __call__

    def __call__(self, request):
        retval = self.HttpResponseObject()

        def start_response(status, headers):
            # Status is one of spyne.const.http
            status, reason = status.split(' ', 1)

            retval.status_code = int(status)
            for header, value in headers:
                retval[header] = value

        environ = request.META.copy()

        # FIXME: No idea what these two did.
        #        They were commented out to fix compatibility issues with
        #        Django-1.2.x
        # See http://github.com/arskom/spyne/issues/222.

        # If you don't override wsgi.input django and spyne will read
        # the same buffer twice. If django read whole buffer spyne
        # would hang waiting for extra request data. Use DjangoServer instead
        # of monkeypatching wsgi.inpu.

        #environ['wsgi.input'] = request
        #environ['wsgi.multithread'] = False

        response = WsgiApplication.__call__(self, environ, start_response)
        self.set_response(retval, response)

        return retval
开发者ID:josjevv,项目名称:spyne,代码行数:30,代码来源:django.py


示例12: __call__

    def __call__(self, request):
        django_response = HttpResponse()

        def start_response(status, headers):
            status, reason = status.split(' ', 1)

            django_response.status_code = int(status)
            for header, value in headers:
                django_response[header] = value

        environ = request.META.copy()
        environ['wsgi.input'] = request
        environ['wsgi.multithread'] = False
        response = WsgiApplication.__call__(self, environ, start_response)
        #TODO: можно сказать, что это костыль, без него не работает.
        #Может быть когда то spyne научится делать это сам, как надо sopa клиенту qiwi
        data = (u"".join(response))\
                    .replace('tns:updateBillResult', 'updateBillResult')

        if self.debug_mode is None:
            self.debug_mode = bool(settings.DEBUG)

        if self.debug_mode:
            logger = logging.getLogger(LOGGER_NAME)
            logger.debug(u'soap response content: {0}'.format(data))

        django_response.content = data
        if django_response.has_header('Content-Length'):
            django_response['Content-Length'] = len(data)

        return django_response
开发者ID:jcfromsiberia,项目名称:qiwi-for-django,代码行数:31,代码来源:handler.py


示例13: __call__

    def __call__(self, request):
        retval = Response()

        def start_response(status, headers):
            status, reason = status.split(' ', 1)

            retval.status_int = int(status)
            for header, value in headers:
                retval.headers[header] = value

        response = WsgiApplication.__call__(self, request, start_response)
        retval.body = "".join(response)

        return retval
开发者ID:Bernie,项目名称:spyne,代码行数:14,代码来源:pyramid.py


示例14: __call__

    def __call__(self, request):
        pyramid_response = Response()
        def start_response(status, headers):
            status, reason = status.split(' ', 1)

            pyramid_response.status_int = int(status)
            pyramid_response.headers["Cache-Control"] = "no-cache, must-revalidate"
            pyramid_response.headers["Expires"] = "Sat, 26 Jul 1997 05:00:00 GMT"
            for header, value in headers:
                pyramid_response.headers[header] = value

        response = WsgiApplication.__call__(self, request, start_response)
        pyramid_response.body = "\n".join(response)
        return pyramid_response
开发者ID:Bluehorn,项目名称:spyne,代码行数:14,代码来源:__init__.py


示例15: __call__

    def __call__(self, request):
        retval = self.HttpResponse

        def start_response(status, headers):
            status, reason = status.split(' ', 1)

            retval.status_code = int(status)
            for header, value in headers:
                retval[header] = value

        environ = request.META.copy()
        environ['wsgi.input'] = request
        environ['wsgi.multithread'] = False

        response = WsgiApplication.__call__(self, environ, start_response)
        self.set_response(self, retval, response)

        return retval
开发者ID:norox,项目名称:spyne,代码行数:18,代码来源:django.py


示例16: test_multiple

    def test_multiple(self):
        class SomeService(ServiceBase):
            @srpc(String(max_occurs='unbounded'), _returns=String)
            def some_call(s):
                return '\n'.join(s)

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': 's=1&s=2',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
        }, 'some-content-type')

        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)

        assert ctx.out_string == ['1\n2']
开发者ID:anthonyrisinger,项目名称:spyne,代码行数:21,代码来源:test_http.py


示例17: __call__

    def __call__(self, request):
        django_response = HttpResponse()

        def start_response(status, headers):
            status, reason = status.split(' ', 1)

            django_response.status_code = int(status)
            for header, value in headers:
                django_response[header] = value

        environ = request.META.copy()
        environ['wsgi.input'] = request
        environ['wsgi.multithread'] = False

        response = WsgiApplication.__call__(self, environ, start_response)

        django_response.content = "\n".join(response)

        return django_response
开发者ID:Bluehorn,项目名称:spyne,代码行数:19,代码来源:__init__.py


示例18: test_nested_flatten

    def test_nested_flatten(self):
        class CM(ComplexModel):
            i = Integer
            s = String

        class CCM(ComplexModel):
            c = CM
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(CCM, _returns=String)
            def some_call(ccm):
                return repr(ccm)

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        initial_ctx = WsgiMethodContext(server, {
            'QUERY_STRING': 'ccm_i=1&ccm_s=s&ccm_c_i=3&ccm_c_s=cs',
            'PATH_INFO': '/some_call',
            'REQUEST_METHOD': 'GET',
            'SERVER_NAME': "localhost",
        }, 'some-content-type')

        ctx, = server.generate_contexts(initial_ctx)

        server.get_in_object(ctx)
        assert ctx.in_error is None

        server.get_out_object(ctx)
        assert ctx.out_error is None

        server.get_out_string(ctx)

        print(ctx.out_string)
        assert ctx.out_string == ["CCM(i=1, c=CM(i=3, s='cs'), s='s')"]
开发者ID:Bluehorn,项目名称:spyne,代码行数:37,代码来源:test_http.py


示例19: test_rules

    def test_rules(self):
        _int = 5
        _fragment = 'some_fragment'

        class SomeService(ServiceBase):
            @srpc(Integer, _returns=Integer, _patterns=[
                                      HttpPattern('/%s/<some_int>'% _fragment)])
            def some_call(some_int):
                assert some_int == _int

        app = Application([SomeService], 'tns', in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        environ = {
            'QUERY_STRING': '',
            'PATH_INFO': '/%s/%d' % (_fragment, _int),
            'SERVER_PATH':"/",
            'SERVER_NAME': "localhost",
            'wsgi.url_scheme': 'http',
            'SERVER_PORT': '9000',
            'REQUEST_METHOD': 'GET',
        }

        initial_ctx = WsgiMethodContext(server, environ, 'some-content-type')

        ctx, = server.generate_contexts(initial_ctx)

        foo = []
        for i in server._http_patterns.iter_rules():
            foo.append(i)

        assert len(foo) == 1
        print foo
        assert ctx.descriptor is not None

        server.get_in_object(ctx)
        assert ctx.in_error is None

        server.get_out_object(ctx)
        assert ctx.out_error is None
开发者ID:mescam,项目名称:spyne,代码行数:40,代码来源:test_http.py


示例20: test_rules

    def test_rules(self):
        _int = 5
        _fragment = "some_fragment"

        class SomeService(ServiceBase):
            @srpc(Integer, _returns=Integer, _patterns=[HttpPattern("/%s/<some_int>" % _fragment)])
            def some_call(some_int):
                assert some_int == _int

        app = Application([SomeService], "tns", in_protocol=HttpRpc(), out_protocol=HttpRpc())
        server = WsgiApplication(app)

        environ = {
            "QUERY_STRING": "",
            "PATH_INFO": "/%s/%d" % (_fragment, _int),
            "SERVER_PATH": "/",
            "SERVER_NAME": "localhost",
            "wsgi.url_scheme": "http",
            "SERVER_PORT": "9000",
            "REQUEST_METHOD": "GET",
        }

        initial_ctx = WsgiMethodContext(server, environ, "some-content-type")

        ctx, = server.generate_contexts(initial_ctx)

        foo = []
        for i in server._http_patterns:
            foo.append(i)

        assert len(foo) == 1
        print(foo)
        assert ctx.descriptor is not None

        server.get_in_object(ctx)
        assert ctx.in_error is None

        server.get_out_object(ctx)
        assert ctx.out_error is None
开发者ID:akash0675,项目名称:spyne,代码行数:39,代码来源:test_http.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python wsdl.build_app函数代码示例发布时间:2022-05-27
下一篇:
Python wsgi._parse_qs函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap