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


Python ServerBase.get_out_string方法代码示例

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


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

示例1: test_complex

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

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

        from rpclib.server import ServerBase

        server = ServerBase(app)
        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)
开发者ID:mardiros,项目名称:rpclib,代码行数:34,代码来源:test_http.py

示例2: test_multiple_return

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

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

        from rpclib.server import ServerBase

        server = ServerBase(app)
        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:mardiros,项目名称:rpclib,代码行数:35,代码来源:test_http.py

示例3: test_multiple

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

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

        from rpclib.server import ServerBase

        server = ServerBase(app)
        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:mardiros,项目名称:rpclib,代码行数:27,代码来源:test_http.py

示例4: test_complex

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', JsonObject(), JsonObject(),
                                                                       Wsdl11())
        server = ServerBase(app)
        initial_ctx = MethodContext(server)
        initial_ctx.in_string = ['{"some_call":{"ccm": {"c":{"i":3, "s": "3x"}, "i":4, "s": "4x"}}}']

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

        ret = json.loads(''.join(ctx.out_string))
        print ret

        assert ret['some_callResponse']['some_callResult']['i'] == 4
        assert ret['some_callResponse']['some_callResult']['s'] == '4x'
        assert ret['some_callResponse']['some_callResult']['c']['i'] == 3
        assert ret['some_callResponse']['some_callResult']['c']['s'] == '3x'
开发者ID:surajbarkale,项目名称:rpclib,代码行数:35,代码来源:test_json.py

示例5: test_multiple_return_sd_0

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    def test_multiple_return_sd_0(self):
        class SomeService(ServiceBase):
            @srpc(_returns=Iterable(Integer))
            def some_call():
                return 1, 2

        app = Application([SomeService], 'tns', JsonObject(), JsonObject(),
                                                                       Wsdl11())

        server = ServerBase(app)
        initial_ctx = MethodContext(server)
        initial_ctx.in_string = ['{"some_call":{}}']

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

        assert list(ctx.out_string) == ['{"some_callResponse": {"some_callResult": {"integer": [1, 2]}}}' ]

        server = ServerBase(app)
        initial_ctx = MethodContext(server)
        initial_ctx.in_string = ['{"some_call":[]}']

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

        assert list(ctx.out_string) == ['{"some_callResponse": {"some_callResult": {"integer": [1, 2]}}}']
开发者ID:surajbarkale,项目名称:rpclib,代码行数:32,代码来源:test_json.py

示例6: test_primitive_only

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(app, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)

        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        print "!", ctx.in_object
        server.get_out_object(ctx)

        try:
            server.get_out_string(ctx)
        except:
            pass
        else:
            raise Exception("Must Fail")
开发者ID:azurit,项目名称:rpclib,代码行数:36,代码来源:test_http.py

示例7: test_multiple_return

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', Wsdl11(), HttpRpc(), HtmlMicroFormat())

        from rpclib.server.wsgi import WsgiMethodContext

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

        from rpclib.server import ServerBase

        server = ServerBase(app)
        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:mardiros,项目名称:rpclib,代码行数:30,代码来源:test_html.py

示例8: test_simple

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    def test_simple(self):
        class SomeService(ServiceBase):
            @srpc(String, _returns=String)
            def some_call(s):
                return s

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HtmlMicroFormat())

        from rpclib.server.wsgi import WsgiMethodContext

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

        from rpclib.server import ServerBase

        server = ServerBase(app)
        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:mardiros,项目名称:rpclib,代码行数:29,代码来源:test_html.py

示例9: test_primitive_only

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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", Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        ctx = WsgiMethodContext(app, {"QUERY_STRING": "", "PATH_INFO": "/some_call"}, "some-content-type")

        from rpclib.server import ServerBase

        server = ServerBase(app)

        try:
            server.get_in_object(ctx)
            server.get_out_object(ctx)
            server.get_out_string(ctx)
        except ValueError:
            pass
        else:
            raise Exception("Must Fail")
开发者ID:voldmar,项目名称:rpclib,代码行数:30,代码来源:test_http.py

示例10: test_multiple_return

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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", Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        ctx = WsgiMethodContext(app, {"QUERY_STRING": "", "PATH_INFO": "/some_call"}, "some-content-type")

        from rpclib.server import ServerBase

        server = ServerBase(app)
        try:
            server.get_in_object(ctx)
            server.get_out_object(ctx)
            server.get_out_string(ctx)
        except ValueError:
            pass
        else:
            raise Exception("Must Fail")
开发者ID:voldmar,项目名称:rpclib,代码行数:28,代码来源:test_http.py

示例11: test_multiple_dict_array

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    def test_multiple_dict_array(self):
        class SomeService(ServiceBase):
            @srpc(Iterable(String), _returns=Iterable(String))
            def some_call(s):
                return s

        app = Application([SomeService], 'tns', JsonObject(), JsonObject(), Wsdl11())
        server = ServerBase(app)

        initial_ctx = MethodContext(server)
        initial_ctx.in_string = ['{"some_call":{"s":["a","b"]}}']

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

        assert list(ctx.out_string) == ['{"some_callResponse": {"some_callResult": {"string": ["a", "b"]}}}']
开发者ID:surajbarkale,项目名称:rpclib,代码行数:20,代码来源:test_json.py

示例12: test_multiple_dict_complex_array

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    def test_multiple_dict_complex_array(self):
        class CM(ComplexModel):
            i = Integer
            s = String

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

        class ECM(CCM):
            d = DateTime

        class SomeService(ServiceBase):
            @srpc(Iterable(ECM), _returns=Iterable(ECM))
            def some_call(ecm):
                return ecm

        app = Application([SomeService], 'tns', JsonObject(), JsonObject(), Wsdl11())
        server = ServerBase(app)

        initial_ctx = MethodContext(server)
        initial_ctx.in_string = ['{"some_call": {"ecm": [{"c": {"i":3, "s": "3x"}, "i":4, "s": "4x", "d": "2011-12-13T14:15:16Z"}]}}']

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

        ret = json.loads(''.join(ctx.out_string))
        print ret
        assert ret['some_callResponse']
        assert ret['some_callResponse']['some_callResult']
        assert ret['some_callResponse']['some_callResult']['ECM']
        assert ret['some_callResponse']['some_callResult']['ECM'][0]
        assert ret['some_callResponse']['some_callResult']['ECM'][0]["c"]
        assert ret['some_callResponse']['some_callResult']['ECM'][0]["c"]["i"] == 3
        assert ret['some_callResponse']['some_callResult']['ECM'][0]["c"]["s"] == "3x"
        assert ret['some_callResponse']['some_callResult']['ECM'][0]["i"] == 4
        assert ret['some_callResponse']['some_callResult']['ECM'][0]["s"] == "4x"
        assert ret['some_callResponse']['some_callResult']['ECM'][0]["d"] == "2011-12-13T14:15:16+00:00"
开发者ID:surajbarkale,项目名称:rpclib,代码行数:44,代码来源:test_json.py

示例13: test_nested_flatten

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(app, {
            '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')

        from rpclib.server import ServerBase

        server = ServerBase(app)
        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:mardiros,项目名称:rpclib,代码行数:42,代码来源:test_http.py

示例14: test_primitive_only

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    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', JsonObject(), JsonObject(),
                                                                       Wsdl11())

        server = ServerBase(app)
        initial_ctx = MethodContext(server)
        initial_ctx.in_string = ['{"some_call":[]}']

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

        assert list(ctx.out_string) == ['{"some_callResponse": {"some_callResult": {"i": 5, "s": "5x"}}}']
开发者ID:surajbarkale,项目名称:rpclib,代码行数:25,代码来源:test_json.py

示例15: test_rpc

# 需要导入模块: from rpclib.server import ServerBase [as 别名]
# 或者: from rpclib.server.ServerBase import get_out_string [as 别名]
    def test_rpc(self):
        import sqlalchemy
        from sqlalchemy import sql

        class KeyValuePair(TableSerializer, self.DeclarativeBase):
            __tablename__ = 'key_value_store'
            __namespace__ = 'punk'

            key = Column(sqlalchemy.String(100), nullable=False, primary_key=True)
            value = Column(sqlalchemy.String, nullable=False)

        self.metadata.create_all(self.engine)

        import hashlib

        session = self.Session()

        for i in xrange(1,10):
            key = str(i)
            m = hashlib.md5()
            m.update(key)
            value = m.hexdigest()

            session.add(KeyValuePair(key=key, value=value))

        session.commit()

        from rpclib.service import ServiceBase
        from rpclib.model.complex import Array
        from rpclib.model.primitive import String

        class Service(ServiceBase):
            @rpc(String(max_occurs='unbounded'),
                    _returns=Array(KeyValuePair),
                    _in_variable_names={
                        'keys': 'key'
                    }
                )
            def get_values(ctx, keys):
                session = self.Session()

                return session.query(KeyValuePair).filter(sql.and_(
                    KeyValuePair.key.in_(keys)
                )).order_by(KeyValuePair.key)

        application = Application([Service],
            interface=Wsdl11(),
            in_protocol=HttpRpc(),
            out_protocol=Soap11(),
            name='Service', tns='tns'
        )

        from rpclib.server.wsgi import WsgiMethodContext

        ctx = WsgiMethodContext(application,{
            'QUERY_STRING': 'key=1&key=2&key=3',
            'PATH_INFO': '/get_values',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(application)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)

        i = 0
        for e in ctx.out_document[0][0][0]:
            i+=1
            key = str(i)
            m = hashlib.md5()
            m.update(key)
            value = m.hexdigest()

            _key = e.find('{%s}key' % KeyValuePair.get_namespace())
            _value = e.find('{%s}value' % KeyValuePair.get_namespace())

            print _key, _key.text
            print _value, _value.text

            self.assertEquals(_key.text, key)
            self.assertEquals(_value.text, value)
开发者ID:cloudappsetup,项目名称:rpclib,代码行数:84,代码来源:test_sqla.py


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