[Twisted-Python] Another silly XML-RPC question

Steve Waterbury golux at comcast.net
Tue Aug 26 01:29:06 MDT 2003


Dave Peticolas wrote:
> On Mon, 2003-08-25 at 20:50, Steve Freitas wrote:

>>So how do I get a twisted xmlrpc function to accept a struct? I assume I have 
>>to take it into a string and somehow serialize it into a dictionary using 
>>XML-RPC magic I haven't learned about, as in...
>>
>>def xmlrpc_foo(self, myDict):
>>        ...magically transform myDict (a string) into myNewDict (a dict!)...
>>        return myNewDict['x']
>>
>>Any help is appreciated! Thanks!
> 
> 
> No, you just send a python dictionary. XML-RPC will serialize
> it as a struct and it will be converted back to a Python dict
> before it is passed to your handler.
> 
> If you're using Twisted on the client side as well:
> 
>   proxy.callRemote('foo', {'x':42})

Or you can use objects instead of structs, jelly them,
and send the jellied objects over xmlrpc -- xmlrpc has
no problem with nested lists, which is what jelly
produces.  Good ol' jelly!  Caveat:  the objects'
attributes have to be jellyable (some types aren't).
This is analogous to the PB "copyable" paradigm.

- Steve.





More information about the Twisted-Python mailing list