| 1 |
============== |
| 2 |
Django XML-RPC |
| 3 |
============== |
| 4 |
|
| 5 |
**Django_xmlrpc** offers a means by which a Django developer can expose their |
| 6 |
views (or indeed any other function) using XML-RPC. |
| 7 |
|
| 8 |
This is a fork of the original version made by Svetlyak40wt compatible with |
| 9 |
Django >= 1.8 and Python >= 2.5. |
| 10 |
|
| 11 |
If you want to use **django_xmlrpc** for an older version of Django or Python, |
| 12 |
please use an old release. |
| 13 |
|
| 14 |
.. contents:: |
| 15 |
|
| 16 |
Installation |
| 17 |
============ |
| 18 |
|
| 19 |
You could retrieve the last sources from |
| 20 |
http://github.com/Fantomas42/django-xmlrpc and run the installation script |
| 21 |
:: |
| 22 |
|
| 23 |
$ python setup.py install |
| 24 |
|
| 25 |
or use pip :: |
| 26 |
|
| 27 |
$ pip install -e git://github.com/Fantomas42/django-xmlrpc.git#egg=django-xmlrpc |
| 28 |
|
| 29 |
Usage |
| 30 |
===== |
| 31 |
|
| 32 |
Register **django_xmlrpc** in your INSTALLED_APPS section of your project' |
| 33 |
settings. |
| 34 |
|
| 35 |
There are two ways to register methods that you want to handle: |
| 36 |
|
| 37 |
In your project's settings. :: |
| 38 |
|
| 39 |
XMLRPC_METHODS = (('path.to.your.method', 'Method name'), |
| 40 |
('path.to.your.othermethod', 'Other Method name'),) |
| 41 |
|
| 42 |
In a file called ``xmlrpc.py`` in your application directory. :: |
| 43 |
|
| 44 |
XMLRPC_METHODS = (('path.to.your.method', 'Method name'), |
| 45 |
('path.to.your.othermethod', 'Other Method name'),) |
| 46 |
|
| 47 |
A registered method should look like this: :: |
| 48 |
|
| 49 |
from django_xmlrpc.decorators import xmlrpc_func |
| 50 |
|
| 51 |
@xmlrpc_func(returns='string', args=['string']) |
| 52 |
def test_xmlrpc(text): |
| 53 |
"""Simply returns the args passed to it as a string""" |
| 54 |
return "Here's a response! %s" % str(text) |
| 55 |
|
| 56 |
Finally we need to register the url of the XML-RPC server. Insert something |
| 57 |
like this in your project's urls.py: :: |
| 58 |
|
| 59 |
from django_xmlrpc.views import handle_xmlrpc |
| 60 |
|
| 61 |
url(r'^xmlrpc/$', handle_xmlrpc, name='xmlrpc'), |