0

I need to send an object through XML-RPC in python. My object consist of composite data type to populate a tree structure:

class Node(object):
'''Composite data type '''
def __init__(self, pData, pParent=None):
    self.mData = pData
    self.mParent = pParent
    self.mChildren = []

self.mParent is reference to its parent node. So I have a recursive data structures to create this structure. When I try to send this data type directly by XML-RPC, it gives this error:

xmlrpclib.Fault: <Fault 1: "<type 'exceptions.TypeError'>:cannot marshal recursive dictionaries">

I think this exception raised due to its complex structure. Because xml-rpc supports only basic data types. I couldn't use dictionaries, because I need to have the references in my client peer. When i use dictionaries with references, it gives the same error above. I couldn't use pickle, It needs to be language independent.

Do you have any suggestion to send an object through XML-RPC natively? Maybe how to create my own data type to send it in xml format?

Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187
zekifh
  • 169
  • 1
  • 2
  • 10

1 Answers1

1

Look at

http://www.xs4all.nl/~irmen/pyro3/

when you want to transfer Python objects over the wire.

Since XMLRPC is based on XML -as the name implies - you can not transfer Python objects over the wire without serialization.

  • thanks for reply. As you said, it needs to be serialized in suitable XML representations before sending object. For example, when I send a string variable, XML-RPC generates automatically variable. So is it also possible that I serialize my object in xml-format (without pickle, changing the code in xmlrpclib) and send it to another peer? – zekifh May 21 '11 at 17:00