Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 18th, 2005, 06:39 PM
Gabriel PASTOR
Guest
 
Posts: n/a
Default xmlrpclib - error marshalling new-style classes

I'm trying to send object using xmlrpclib, but it seems that classes inheriting from object cannot be marshalled. Here is an example:

-------- server.py --------
import xmlrpclib, SimpleXMLRPCServer

class MyObject(object):
def __init__(self,name):
self._name=name

def getMyObject(name):
obj = MyObject(name)
return obj

if __name__ == "__main__":
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost" , 8888))
print 'server running on port 8888'
server.register_function(getMyObject)
server.handle_request()

---- client.py ------
import xmlrpclib, SimpleXMLRPCServer
server = xmlrpclib.ServerProxy("http://localhost:8888")
obj = server.getMyObject('john')
print obj

I get the following error
xmlrpclib.Fault: <Fault 1: "exceptions.TypeError:cannot marshal <class '__main__
..MyObject'> objects">

And if the class MyObject doesn't inherit from object then the program runs correctly. I have this problem using python 2.3 and the problem is exacltly the same with python 2.4 beta1

Am I doing something wrong or is it a bug in xmlrpclib ?

Regards,

gp




  #2  
Old July 18th, 2005, 06:40 PM
infidel
Guest
 
Posts: n/a
Default Re: xmlrpclib - error marshalling new-style classes

The XML-RPC protocol only "understands" a specific set of "types".
Basically they amount to numbers, strings, dates, arrays (lists/tuples)
and structs (dicts) containing such items. xmlrpclib has no way of
knowing how to map your class to such primitive types and reconstruct
it on the "other side".

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.