472,133 Members | 998 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

question: howto transfer objects between server and client?

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
3 2339
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
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
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.

Similar topics

1 post views Thread by Grant Collins | last post: by
11 posts views Thread by CSN | last post: by
10 posts views Thread by Lars Grøtteland | last post: by
23 posts views Thread by barryfz | last post: by
6 posts views Thread by preport | last post: by
5 posts views Thread by jehugaleahsa | last post: by
11 posts views Thread by Bill Davy | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.