wsgiservlets.JSONRPCServer

class wsgiservlets.JSONRPCServer

JSON-RPC is a remote procecure call protocol using JSON for encoding messages between client and server.

JSONRPCServer is a WSGIServlet providing JSON-RPC services to clients.

Any method with prefix rpc_ is available to be called by a client (which should call the method without the prefix). Any method not prefixed with rpc_ is not available to clients and becomes a private method of the server implementation.

Here’s an example servlet with one private method and one public method:

from wsgiservlets import JSONRPCServer

class myrpcserver(JSONRPCServer):

    def priv(self):
        # this method could not be called from a client
        # because it does not begin with *rpc_*
        pass

    def rpc_echo_upper(self, s):

        # this method is available to clients as
        # **echo_upper(str)**

        return s.upper()                                 

The tutorial that comes with WSGIServlets has an example of JSONRPCServer in action.

Previous topic

wsgiservlets.Dispatcher

Next topic

wsgiservlets.HTTPResponse

This Page