473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 2397
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Grant Collins | last post by:
Hi, I am writing a client / server application for one of my University projects and I would like some guidance reguarding the transfer of data from the client to the server. I have two...
0
by: AMDIRT | last post by:
I have a few questions about IssueVision (from WindowsForms) concerning its scalability and performance. Rather, if I were to implement techniques described here into another application, how...
11
by: CSN | last post by:
Is it possible to iterate over an array in plpgsql? Something like: function insert_stuff (rel_ids int) .... foreach rel_ids as id insert into table (rel_id, val) values (id, 5);
10
by: Lars Grøtteland | last post by:
Hello! Was wondering how I can create a copy of one database? FYI I'm not interrested in the data, just the fields and triggers, and so on. Which way is the easiest? Do I create a script and...
4
by: Brian | last post by:
Hi, I'm trying to make an online FTP utility in C# ASP.NET using MSINET.ocx (an active X control a.k.a. "Microsoft Internet Transfer Control") I've added the reference into my project and have...
23
by: barryfz | last post by:
I need to be able to move from one web app on my server to another on the same server and preserve the session state. I have played with server.transfer but I get an error saying I can't do this....
6
by: preport | last post by:
I have a webservice that returns data from a database. Our services (the clients) have been blowing up because of illegal character problems. Is there anything I can do on the server side to...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
11
by: Bill Davy | last post by:
I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.