每当我尝试使用带有第二个对象的属性(bClass)传递一个对象(aClass)时,我得到:
Unpersistable('不可替代的数据:类amodule.bClass的实例被视为不安全')
aClass是可复制的并且没有被冻结,bClass不是。
这是我的代码:
server.py:
from twisted.application import internet, service
from twisted.spread import pb
from amodule import PBServer
application = service.Application("Test app")
# Prepare managers
clientManager = internet.TCPServer(8282, pb.PBServerFactory(PBServer()));
clientManager.setServiceParent(application)
if __name__ == '__main__':
print "Run with twistd"
import sys
sys.exit(1)
amodule.py:
from twisted.spread import pb
class bClass:
"""This is not a Copyable class
"""
class aClass(pb.RemoteCopy, pb.Copyable):
b = bClass()
pb.setUnjellyableForClass(aClass, aClass)
class PBServer(pb.Root):
def remote_echo(self, a):
return a.b
无论如何要取消aClass及其包含的所有对象?因为无聊的包含对象很头疼,可能会变成脏代码......
答案 0 :(得分:2)