Simple and modern JSON-RPC and XML-RPC server implementation for Django
Project description
Description
Django-modern-rpc provides a simple solution to implement a remote procedure call (RPC) server as part of your Django project. It supports all major Django and Python versions.
Project’s main features are:
Simple and pythonic API
Python 2.7, 3.3, 3.4, 3.5 and 3.6
Django 1.8, 1.9, 1.10 and 1.11
XML-RPC and JSON-RPC 2.0 support (JSON-RPC 1.0 not supported)
HTTP Basic Auth support
Custom authentication support
Automatic protocol detection based on request’s Content-Type header
High-level error management based on exceptions
Multiple entry points, with specific methods and protocol attached
RPC Methods documentation generated automatically, based on docstrings
System introspection methods:
system.listMethods()
system.methodSignature()
system.methodHelp()
system.multicall() (XML-RPC only, using specification from https://mirrors.talideon.com/articles/multicall.html)
Quick start
Use pip to install the package in your environment:
pip install django-modern-rpc
Add it to your Django applications, in settings.py:
INSTALLED_APPS = [ ... 'modernrpc', ]
Declare an entry point, a view generating correct RPC responses to incoming requests:
# In myproject/rpc_app/urls.py from django.conf.urls import url from modernrpc.views import RPCEntryPoint urlpatterns = [ url(r'^rpc/', RPCEntryPoint.as_view()), ]
Use @rpc_method to register a global function in django-moder-rpc registry:
# In myproject/rpc_app/rpc_methods.py from modernrpc.core import rpc_method @rpc_method def add(a, b): return a + b
Declare the list of python modules containing your RPC methods, in settings.py:
MODERNRPC_METHODS_MODULES = [ 'rpc_app.rpc_methods' ]
Now, you can call the method add from a client:
>>> from xmlrpc.client import ServerProxy
>>> client = ServerProxy('http://localhost:8000/rpc/')
>>> print(client.add(2, 3))
5
For more information, please read the full documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_modern_rpc-0.7.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dec5c24fde4ed72ffca0988e9a87a7735df3e129f4e7e61887c8e58196074897 |
|
MD5 | 15e4d9ec4ca45fb38c0540b28bf0ded5 |
|
BLAKE2b-256 | 8e7581c0147e01b6e5c4e7a37b75ed492e059b926b65a21f2ca3740ebe516cb7 |