我在項目中使用Pyro,似乎無法理解如何通過電線傳輸完整對象。對象是而不是分佈式(我的分佈式對象工作得很好),但應該作爲已有的分佈式對象的參數。通過Pyro傳輸對象
我的對象是派生自包含一些方法和一些變量 - 一個整數和一個列表的自定義類。該類可用於服務器和客戶端。當使用我的對象作爲分佈對象的方法的參數時,整數變量正確地被「接收」,但是列表是空的,儘管我可以在它「發送」之前看到它包含值。
這是爲什麼?
短的類版本:
class Collection(Pyro.core.ObjBase):
num = 0
operations = [("Operation:", "Value:", "Description", "Timestamp")]
def __init__(self):
Pyro.core.ObjBase.__init__(self)
def add(self, val, desc):
entry = ("Add", val, desc, strftime("%Y-%m-%d %H:%M:%S"))
self.operations.append(entry)
self.num = self.num + 1
def printop(self):
print "This collection will execute the following operations:"
for item in self.operations:
print item
的receving方法在分佈式對象:
def apply(self, collection):
print "Todo: Apply collection"
#op = collection.getop()
print "Number of collected operations:", collection.a
collection.printop()