472,789 Members | 1,131 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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):

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

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

---- 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 ?



Jul 18 '05 #1
1 2614
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".

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Larry | last post by:
I've had a production system running for a long time that uses xmlrpclib with timeoutsocket, and with my recent upgrade to 2.3 it's no longer able to use xmlrpclib with the xmlrpc servers I...
by: sashan | last post by:
Hi I'm having trouble using xmlrpclib. I register a function (or class) with the SimpleXMLRPCServer and initiate the server. I then create a ServerProxy object and connect to the xml-rpc...
by: p2esp | last post by:
Hello, I'm using the xmlrpclib module to contact an XMLRPC server that takes a long time to send results back. My client timeouts. The question is whether there is a way to have an xmlrpclib...
by: Alan Little | last post by:
I'm trying to write a generic weblog update notifier using xmlrpclib, starting with technorati. What I want to do is something like this : XML config file that would look like this: <server...
by: writeson | last post by:
Hi, I tried the xmlrpclib examples from the Python Cookbook and had a problem. The example works fine so long as the server and client are on the same machine. But as soon as I try to run the...
by: Rune Froysa | last post by:
Trying something like:: import xmlrpclib svr = xmlrpclib.Server("") svr.test("\x1btest") Failes on the server with:: xml.parsers.expat.ExpatError: not well-formed (invalid...
by: Willi Langenberger | last post by:
Hi! We have an application server (Zope) and make heavy use of xml-rpc. One problem arised, when we tried to return a zope.DateTime instance. xmlrpclib (naturally) knows nothing about...
by: DazedAndConfused | last post by:
I converted a C# example of using dll crypt32 to VB .NET. The converted example fails when Encypting/Decypting. I found that if instead of defining a variable as and setting the values for...
by: gregarican | last post by:
Looking at the docs for xmlrpclib I didn't see a way to pass a client call with an expressed timeout value. What is the easiest way to accomplish this? Do I have to tap into the underlying HTTP...
by: Arno Stienen | last post by:
Perhaps I should be a bit more specific. When using this code to connect to a remote XML-RPC server (C++, xmlrpc++0.7 library): import xmlrpclib server =...
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.