This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A bare bones JSONRPC 2.0 implementation in python (that you can flesh out)

from pyjrpc import JSONRPC
import operator

methods = {
    "add": operator.add,
    "sub": operator.sub,

jsonrpc_handler = JSONRPC(methods)

print jsonrpc_handler('{"jsonrpc":"2.0", "id":"A", "method":"add", "params":[2,3]}')
# {"jsonrpc": "2.0", "id": "A", "result": 5}
print jsonrpc_handler('{"jsonrpc":"2.0", "id":"B", "method":"sub", "params":[3]}')
# {"jsonrpc": "2.0", "id": "B", "error": {"message": "Invalid parameters", "code": -32602}}
print jsonrpc_handler('{"jsonrpc":"2.0", "id":"C", "method":"div", "params":[2,3]}')
# {"jsonrpc": "2.0", "id": "C", "error": {"message": "Method not found", "code": -32601}}
print jsonrpc_handler(
        '[{"jsonrpc":"2.0", "id":"D1", "method":"add", "params":[1,1]},'
        '{"jsonrpc":"2.0", "id":"D2", "method":"sub", "params":[63,21]}]'
# [{"jsonrpc": "2.0", "id": "D1", "result": 2},
#  {"jsonrpc": "2.0", "id": "D2", "result": 42}]

Only the spec

pyjrpc aims to be a bare implementation of the JSON-RPC 2.0 specification in python, with minimum dependancies.

pyjrpc aims to be easy to use, easy to plug and easy to extend.

Server not included

pyjrpc does not implement the transport layer, it doesn’t even consider it.

In it’s simplest interpretation, the JSONRPC protocol only deals with requests and responses, not their transportation. This is why pyjrpc won’t do anything about it.

However, shall you have the means to transport a string, pyjrpc is dead easy to plug : its main object is a callable which takes a string request parameter and applies the protocol upon it. It might return a string response if you’re gentle enough.

Say my name

pyjrpc does not implement function registering magic. Keep it simple, stupid.

Names are identified by their method, or maybe the other way. Therefore, pyjrpc only assumes that the method map passed as a parameter to the JSONRPC() constructor implements __getitem__. Yup, you can use a dict.

If you really WANT to implement the magic, feel free to do it. just implement __getitem__ so that methods[name] will return the function you want. Yeah, service introspection, namespaces, fuzzy naming, you can do it all… wait, fuzzy naming ? I hope you’re not serious about that but, hey, whatever.

Cascading handlers

TODO : A tale about handler decoration, and all the amazing things you can do with that.

Client POV

raise NotImplementedError


pyjrpc has been seen working live on python 2.7.


Run python test

Moar docz, moar examplz


Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyjrpc-0.1.1.tar.gz (4.2 kB) Copy SHA256 Checksum SHA256 Source Nov 17, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting