【发布时间】:2011-05-02 12:53:16
【问题描述】:
我正在做一个分布式处理项目。 我需要将我的复合数据类型发送给另一个对等点,这样我就可以在其他对等点中使用它来填充我的 TreeView 结构。 我的“tsk_composite”模块中有这两个类, 我的复合数据节点:
class CTskNode(object):
def __init__(self, pData, pParent = None):
self.mData = pData
self.mParent = pParent
self.mChildren = []
我的主类发送树结构的RootNode:
class CTskComposite(object):
...
def getRootNode(self):
self.getImagePartitions()
return self.mParent
def getImagePartitions(self):
#I use this method to create my parentRoot with recursive function
#it works good
我使用 cPickle 和这段代码发送我的复合数据:
def _composite(self, pArgs):
self.mComposite = CTskComposite(pArgs)
self.mCompositeRootNode = self.mComposite.getRootNode()
return cPickle.dumps(self.mCompositeRootNode)
当我在第二个对等方中收到复合数据时,它会给出以下错误消息:
ImportError: No module named tsk_composite
当我在我的第二个对等方中创建一个名为“tsk_composite”的 emty 模块时,它会给出这个错误:
AttributeError: 'module' object has no attribute 'CTskNode'
当我刚刚在我的第二个同行的模块中编写这行代码时,它运行良好。
class CTskNode(object):pass
其实我不需要这个模块和类,我怎样才能通过 cpickle 将模块和类名导入其他对等点?
【问题讨论】:
标签: python xml-rpc pickle composite importerror