【发布时间】:2011-08-31 07:02:18
【问题描述】:
我有一个通过 xml-rpc 发送字典的简单示例:
class CTest(object):
def __init__(self):
self.node1 = {'data':'zek', 'parent':{}, 'children':[]}
self.node2 = {'data':'bill', 'parent':{}, 'children':[]}
self.node1['children'].append(self.node2)
self.node2['parent'] = self.node1
def getNode(self):
return self.node1
我有两个字典:node2 是 node1 的孩子,同时 node2 有 node1 的引用作为父变量。 所以它是一个递归字典。当我尝试通过 XML-RPC 发送 node1 时,我得到了这个异常:
#Command to execute xml-rpc dump method for serialization
test = CTest()
xmlrpclib.dumps((test,), 'Node Object')
#Exception
raise TypeError, "cannot marshal recursive dictionaries"
是否可以通过 XML-RPC 发送 node1(不改变字典结构)?
谢谢。
【问题讨论】:
标签: python recursion dictionary marshalling xml-rpc