[Twisted-Python] call XMLRPC
p.mayers at imperial.ac.uk
Tue Apr 17 04:46:09 EDT 2012
On 04/17/2012 03:38 AM, joel tremblet wrote:
> I try to declare the Proxy(OF_XMLRPC_URL) differently, without success
> Where is my mistake ....
That code is all wrong, and (to be blunt) pretty horrible too.
Why have you re-implemented a HTTP protocol yourself? You're bound to
get this wrong (and in fact have, in several ways). Don't do this. Use
the HTTP stack that comes with Twisted.
Anyway, your major mistake in the 1st example is that, at the end of the
lineReceived method, you always call the sendResponse() method. This
happens immediately, before the XMLRPC reply has come back, so your code
sends "no value". You need to attach the sendResponse method to the
deferred returned from the xmlrpc call.
I would junk it and start again, like this:
from twisted.web import server, resource, xmlrpc, http
proxy = xmlrpc.Proxy(XMLRPC_URL)
isLeaf = True
def render_GET(self, request):
sessid = request.args['sessid']
keyid = request.args['keyid']
d = proxy.callRemote('checkCommand', sessid, keyid)
def _done(self, res, request):
def _err(self, failure, request):
More information about the Twisted-Python