smartrpyc.server.base

The Server object

This is the main Server class.

class smartrpyc.server.base.Server(methods=None)[source]
routes[source]

New in version 0.1-beta6.

Object mapping route names to MethodsRegister objects (or equivalent), containing the actual methods to be exposed.

In the default implementation, this is a defaultdict, allowing to write things like this, without having to care about creating the MethodsRegister object manually:

@server.routes['hello_world'].register
def hello(request):
    return "World"
methods[source]

A property pointing to routes['']. Mostly for background compatibility, this might be deprecated in future versions.

packer

The class to be used for unpacking the message from the client and pack the response before sending. Defaults to CustomMsgPackSerializer.

request_class

The class to be used to represent/wrap received requests. Defaults to Request.

socket[source]

The underlying ZeroMQ REP socket. Do not tamper with this.

middleware

Middleware objects to be called before/after processing requests.

bind(addresses)[source]

Bind the server socket to an address (or a list of)

Beware! Only .bind() or .connect() may be called on a given server instance!

Params addresses:
 A (list of) address(es) to which to bind the server.
connect(addresses)[source]

Connect the server socket to an address (or a list of)

Beware! Only .bind() or .connect() may be called on a given server instance!

Params addresses:
 A (list of) address(es) to which to connect the server.
routes[source]
run()[source]

Start the server listening loop

run_once()[source]

Run once: process a request and send a response

socket[source]

The request object

The Request object holds information about the received request.

class smartrpyc.server.base.Request(raw)[source]

Wrapper for requests from the RPC

args[source]

Positional arguments for the called method

id[source]

Id of the request

kwargs[source]

Keyword arguments for the called method

method[source]

Name of the method to be called

route[source]

Route of the request

server = None