Working with files in a SimpleXMLRPCServver

2006-03-31 Thread Jose Carlos Balderas Alberico
I'm setting up a server accepting XML-RPC callsusing the SimpleXMLRPCServer class. Basically, what I have to do is send a zip-compressed file to the server, have the server unzip it and process it, after processing it the server is supposed to zip the file again, and send it back to the client.


I found a solution, but wanted to ask you if you think there's an easier way of doing this.

What I do at the client first is to compress the file (which is a .txt) using os.system(zip blah blah.txt). Then I obtain the name of the compressed file (let's assume it is blah.zip). Once I have the name of the zip file, I do the following:


fd = open(blah.zip, 'r')bin = xmlrpclib.Binary(fd.read())
server.process(bin)

I obtain a file descriptor, read the data and stuff it in a Binary object, and send it to the server as a parameter to the process method.

Then, at the server script,I create a file, and write into it the data contained in that Binary object using the attribute .data. That way I'll have a new file with the data passed to the server. Then again I use os.system
(...) to unzip the data and recover the original content.

When I need to send content back to the client, the whole process is repeated.

My question is: do you think this is an appropiate way to exchange files between client and server? I'm relativately new to Python, and the task of the file exchange has been assigned to me. I haven't been able to find documentation on the subject, so any help would be appreciated.


If you need any more information about what I'm trying to do, just ask.

Thank you so much for your attention :)

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Working with files in a SimpleXMLRPCServver

2006-03-31 Thread Brian Quinlan
Jose Carlos Balderas Alberico wrote:
 I'm setting up a server accepting XML-RPC calls using the 
 SimpleXMLRPCServer class. Basically, what I have to do is send a 
 zip-compressed file to the server, have the server unzip it and process 
 it, after processing it the server is supposed to zip the file again, 
 and send it back to the client.

Using an XML-RPC server is overkill if you are just sending a single 
file and processing the result. You could just use a HTTP server.

And Python has a library for doing zip processing (zlib), so you don't 
need to bother creating a file just to unzip your data.

Cheers,
Brian
-- 
http://mail.python.org/mailman/listinfo/python-list