On 30/08/2007 12:55 Daniel de la Cuesta wrote:
  Hi,

I am developing an middleware XMLRPC Server. It connects with a mail server and provides and XMLRPC interface to read and send mail.

Is there any way to return the result of the xmlrpc method in deferred's callback?

Is there any way to return a deferred object inside the xmlrpc method?

Is it a good solution using asynchronous chunks (deferreds) inside a synchronous protocol as it is XML-RPC (HTTP)?

I use this pattern on the server side

def xmlrpc_getStuff(self, stuff):
    def fail(_):
        print "Oh dear!"
        return False

    def returnStuff(dbResult):
        otherstuff = doStuffWith(dbResult)
        return otherStuff

    return self.db.getStuff(stuff).addCallbacks(returnStuff, fail)

And this one on the client side

def checkKey(stuff):
    def fail(_):
        return False
    def good(stuff):
        return stuff
return Proxy(xmlServer, allowNone=True).callRemote('getStuff', stuff).addCallbacks(good, fail)

There are better ways depending on what you're really doing..

--
Colin Alston ~ http://www.karnaugh.za.net/
"To the world you may be one person, to one person you may be the world" ~ Rachel Ann Nunes.

Terms and conditions: http://www.karnaugh.za.net/email.rpy

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to