python+XMLRPC: need help

Derek Thomson derek at wedgetail.com
Tue Oct 22 08:02:44 EDT 2002


Hi Ruslan,

Ruslan Spivak wrote:
> Hello python-list users,
> 
> I can use now only python1.5.2. I have installed xmlrpclib.
> Could you help me with the following:
> I have to send(via xmlrpc) a list of value pairs(attribute=value) to remote
> machine in my LAN. I can do this by encoding this into string like
> 'attribute=value;attribute=value;attribute=value;attribute=value' and
> on another machine to decode it, but could I send this like structure,
> not like string and if I should send, for example, list of rows(from
> DB), can I send this by list of structures or there is another
> solution?

Yes, you can send your data as a string, then parse them at the other 
end, but if you do this you're doing the work that XMLRPC can do for you!

You can transfer *any* dictionaries or lists, or combinations of these, 
with XMLRPC.

If I had to send name/value pairs, I would just do this:

remote_obj.method_foo({ name: 'Derek',
                         languages: [ 'Perl', 'Python', 'C', 'C++' ],
                         age: 30 })

... or something. You can of course have more than one argument, and 
return values as well.

These structures will be marshalled into XML, transmitted to the server, 
and on the server side will be converted back into the corresponding 
Python data types. All without you doing anything!

--
D.




More information about the Python-list mailing list