Skip to main content

Tornado XML-RPC server and client

Project description

https://travis-ci.org/mosquito/tornado-xmlrpc.svg Latest Version https://img.shields.io/pypi/wheel/tornado-xmlrpc.svg https://img.shields.io/pypi/pyversions/tornado-xmlrpc.svg https://img.shields.io/pypi/l/tornado-xmlrpc.svg

XML-RPC server and client implementation based on tornado. Using lxml and AsyncHttpClient.

Example:

from tornado_xmlrpc import handler, client
from tornado.testing import *


class XMLRPCTestHandler(handler.XMLRPCHandler):
    def rpc_test(self):
        return None

    def rpc_args(self, *args):
        return len(args)

    def rpc_kwargs(self, **kwargs):
        return len(kwargs)

    def rpc_args_kwargs(self, *args, **kwargs):
        return len(args) + len(kwargs)

    def rpc_exception(self):
        raise Exception("YEEEEEE!!!")


class TestSimple(tornado.testing.AsyncHTTPTestCase):
    def setUp(self):
        super(TestSimple, self).setUp()
        self.server = client.ServerProxy("http://localhost:%d" % self.get_http_port())

    def tearDown(self):
        super(TestSimple, self).tearDown()
        self.server = None

    def get_app(self):
        return Application(handlers=[
            ('/', XMLRPCTestHandler),
        ])

    @gen_test
    def test_00_test(self):
        result = yield self.server.test()
        self.assertIsNone(result)

    @gen_test
    def test_10_args(self):
        result = yield self.server.args(1, 2, 3, 4, 5)
        self.assertEqual(result, 5)

    @gen_test
    def test_20_kwargs(self):
        result = yield self.server.kwargs(foo=1, bar=2)
        self.assertEqual(result, 2)

    @gen_test
    def test_20_kwargs(self):
        result = yield self.server.args_kwargs(1, 2, 3, 4, 5, foo=1, bar=2)
        self.assertEqual(result, 7)

    @gen_test
    def test_30_exception(self):
        try:
            yield self.server.exception()
        except client.RemoteServerException as e:
            self.assertIn("YEEEEEE!!!", e.message)
        else:
            raise RuntimeError("No exception")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tornado-xmlrpc-1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file tornado-xmlrpc-1.1.tar.gz.

File metadata

File hashes

Hashes for tornado-xmlrpc-1.1.tar.gz
Algorithm Hash digest
SHA256 29c95f9162965a558fcc2905542e972a2813ea6fa07660c0ee1435202d221797
MD5 d2fd9d73d8c1263c994ab2720692200d
BLAKE2b-256 28f3853a5072668df471df0619873dfafe45b363c5402048352e452ba96867f8

See more details on using hashes here.

File details

Details for the file tornado-xmlrpc-1.1.macosx-10.11-x86_64.tar.gz.

File metadata

File hashes

Hashes for tornado-xmlrpc-1.1.macosx-10.11-x86_64.tar.gz
Algorithm Hash digest
SHA256 dc33519e518d55c93cd3c1caec4623e3e95fb2c20027a961d13b3bd7bac1e10d
MD5 c512b3a1e19ba7f5aafae8ace574739b
BLAKE2b-256 84f551f5adbbcfdf1978f880b4bca1aac741a2ffe0ca120c6a9895ccb1ef351c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page