By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,554 Members | 907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,554 IT Pros & Developers. It's quick & easy.

question: howto transfer objects between server and client?

P: n/a
Hello community,

maybe one of you can help me out with a question regarding the
transfer of objects betwen client an server:
I have three files:

####### ClassA.py #######
class ClassA:
def setA(self, newA):
self.a = newA
def getA(self):
return self.a

####### client.py #######
import xmlrpclib
from ClassA import *
a = ClassA()
a.setA(4711)
server = xmlrpclib.ServerProxy("http://localhost:8888")
print server.getA(a) # <= here I would like to hand over an
object

####### server.py #######
import SimpleXMLRPCServer
from ClassA import *
class Handler:
def getA(self, aClass):
return aClass.getA() # <- XMLRPC only transports simple types and
dictionaries, but no objects
handler_object = Handler()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost" , 8888))
server.register_instance(handler_object)
print "Listening on port 8888"
server.serve_forever()
The problem is, that though I hand a ClassA object to the XMLRPC
server, the server only receives a dictionary (only transfering simple
objects is a XMLRPC feature: http://docs.python.org/lib/module-xmlrpclib.html)

Since XMLRPC has limited features: Is there any other server/client
technique to transfer objects (not strings, or dictionaries, but self
defined object types) ?

Regards
Bernd

Aug 11 '07 #1
Share this Question
Share on Google+
3 Replies

P: n/a
OpenPavilion wrote:
Since XMLRPC has limited features: Is there any other server/client
technique to transfer objects (not strings, or dictionaries, but self
defined object types) ?
Take a look at Pyro; http://pyro.sourceforge.net

--Irmen
Aug 11 '07 #2

P: n/a
On 11 Aug., 11:21, Irmen de Jong <irmen.NOS...@xs4all.nlwrote:
OpenPavilion wrote:
Since XMLRPC has limited features: Is there any other server/client
technique to transfer objects (not strings, or dictionaries, but self
defined object types) ?

Take a look at Pyro; http://pyro.sourceforge.net

--Irmen
Thanks Irmen,

just found out, that if I use "pickle.dumps(object)" (on client side)
and "pickle.loads(object)" (on server side) before and after sending,
I have access to the object.

I love this python language !
Python is a really, really nice language and I often find that the
solution is easier as I thought in the first place ...

Thanks anyway !!
Regards
Bernd

Aug 11 '07 #3

P: n/a
In message <11**********************@l70g2000hse.googlegroups .com>,
OpenPavilion wrote:
just found out, that if I use "pickle.dumps(object)" (on client side)
and "pickle.loads(object)" (on server side) before and after sending,
I have access to the object.
That's assuming that the client and server can trust each other. If you
can't be sure of that, then this sounds like it could be a security hole.
Aug 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.