An XML-RPC Decorator

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
dispatcher = SimpleXMLRPCDispatcher()
                                                                                
def call_xmlrpc(request):
    """Dispatch XML-RPC requests."""
    if request.method == 'POST':
        # Process XML-RPC call
        response = HttpResponse(mimetype='text/xml')
        response.write(dispatcher._marshaled_dispatch(request.raw_post_data))
        response['Content-length'] = str(len(response.content))
        return response
    else:
        # Show documentation on available methods
        response = HttpResponse()
        t = loader.get_template('xmlrpc.html')
        c = Context({'methods': dispatcher.system_listMethods()})
        response.write(t.render(c))
        return response

def xmlrpc(uri):
    """A decorator for XML-RPC functions."""
    def register_xmlrpc(fn):
        dispatcher.register_function(fn, uri)
        return fn
    return register_xmlrpc

More like this

  1. general-purpose django XMLRC dispatcher by teepark 4 years, 4 months ago
  2. In-memory XML-RPC server based on URL by diverman 2 years, 12 months ago
  3. xmlrpc basic auth by jackherer 5 years, 8 months ago
  4. Format transition middleware by limodou 6 years, 3 months ago
  5. View Permission Decorator Helper by jgeewax 4 years, 11 months ago

Comments

Tobu (on September 28, 2007):

I don't see xmlrpc.html , the template that displays the documentation.

#

Tobu (on September 28, 2007):

Nevermind, this should work:

<html>
<body>
XML-RPC Methods:
<ol>
    {% for method in methods %}
        <li>{{method.name}} &mdash; {{method.signature}}</li>
    {% endfor %}
</ol>
</body>
</html>

#

nyambayar (on July 9, 2010):

great work! thanks

#

(Forgotten your password?)