Skip to main content
Help us improve Python packaging – donate today!

Simple and modern RPC Server for Django

Project Description

TravisStatus RTDBadge

Important note: This project is under development, and is not ready for production environment. You are free to install and test it and provide feedback or make pull request if you want to add a feature, report a bug or try to resolve one of them.

Information

django-modern-rpc is a free, lightweight RPC server for Django projects. It supports JSON-RPC and XML-RPC requests under python 2.7, 3.3, 3.4, 3.5 and Django 1.8, 1.9 and 1.10.

Features

The project is in active development, so all the features are not yet implemented. The list of available features is:

  • XML-RPC & JSON-RPC support
  • Usual errors are correctly reported to user according to the standard
  • Multi-entry point, with specific methods and protocol attached
  • Supported system methods:
    • system.listMethods()
    • system.methodSignature()

Features planned to implement

  • System introspection methods (methodHelp(), etc.)
  • Multi-call

Installation

To install django-modern-rpc, simply use pip:

pip install django-modern-rpc

Quick start

Decorate the methods you want to make reachable from RPC call:

# In myproject/rpc_app/rpc_methods.py
from modernrpc.core import rpc_method

@rpc_method()
def add(a, b):
    return a + b

and make sure these functions are imported at Django startup. A simple way to do that is to import them in your app’s module:

# In myproject/rpc_app/__init__.py
from rpc_app.rpc_methods import add

Now, you have to declare an entry point. This is a standard Django view which will automatically route the request to the right handler (for JSON-RPC or XML-RPC call) and call the method on the server.

# In myproject/rpc_app/urls.py
from django.conf.urls import url

from modernrpc.views import RPCEntryPoint

urlpatterns = [
    url(r'^rpc/', RPCEntryPoint.as_view(), name="rpc_entry_point"),
]

Now, you can call the function add from a client:

try:
    # Python 3
    import xmlrpc.client as xmlrpc_module
except ImportError:
    # Python 2
    import xmlrpclib as xmlrpc_module

client = xmlrpc_module.ServerProxy('http://127.0.0.1:8000/all-rpc/')
print(client.add(2, 3))

# Returns: 5

Release history Release notifications

History Node

0.10.0

History Node

0.9.0

History Node

0.8.1

History Node

0.8.0

History Node

0.7.1

History Node

0.7.0

History Node

0.6.0

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.2

History Node

0.4.1

History Node

0.4.0

History Node

0.3.2

History Node

0.3.1

History Node

0.3.0

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

This version
History Node

0.2.0

History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django_modern_rpc-0.2.0-py2-none-any.whl (14.5 kB) Copy SHA256 hash SHA256 Wheel py2 Oct 5, 2016
django_modern_rpc-0.2.0-py3-none-any.whl (14.5 kB) Copy SHA256 hash SHA256 Wheel py3 Oct 5, 2016
django-modern-rpc-0.2.0.tar.gz (10.1 kB) Copy SHA256 hash SHA256 Source None Oct 5, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page