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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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 <string>variable</string>. 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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.