﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
547	[patch] XMLRPC support for django	upadhyay@…	Adrian Holovaty	"I have a working XMLRPC implementation for django. Here is how to use it:

Add the following to urlpatterns:
{{{
#!python
urlpatterns = patterns('',
    (r'^xmlrpc/', 'myproject.apps.xrpc.views.xrpc.serve'),
)
}}}

I have borrowed code heavily from [http://www.python.org/doc/2.4/lib/simple-xmlrpc-servers.html SimpleXMLRPCServer], which comes with standard python distribution, so we have the same API as described in its documentation, other than the constructor. I have added some security enhancement, so every published method must contain a public attribute which must be set to True before we would serve it.

Here is an example xrpc.py:
{{{
#!python
from django.contrib.xmlrpc import SimpleXMLRPCView

class c:
    def f(self):
        return ""public func, will be served.""
    f.public = True
    def g(self):
        return ""private, wont be served.""
    
serve = SimpleXMLRPCView()
serve.register_instance(c())
}}}

Finally an example of how to use it:
{{{
#!python
>>> import xmlrpclib
>>> server = xmlrpclib.Server('http://localhost:8000/xrpc/')
>>> server.f()
'public func, will be served.'
>>> server.g()
Traceback (most recent call last):
  File ""<interactive input>"", line 1, in ?
  File ""C:\Python24\lib\xmlrpclib.py"", line 1096, in __call__
    return self.__send(self.__name, args)
  File ""C:\Python24\lib\xmlrpclib.py"", line 1383, in __request
    verbose=self.__verbose
  File ""C:\Python24\lib\xmlrpclib.py"", line 1137, in request
    headers
ProtocolError: <ProtocolError for localhost:8000/xrpc/: 500 INTERNAL SERVER ERROR>
>>> 
}}}
Will attach the patch shortly."	enhancement	closed	Tools		normal	duplicate		upadhyay@…	Unreviewed	1	0	0	0	0	0
