[Twisted-Python] Problem passing objects with perspective broker
David Ripton
dripton at ripton.net
Sun Jan 29 01:11:56 EST 2012
On 01/29/12 00:57, Fourat ZOUARI wrote:
> Whenever i try to pass an object (aClass) with a property with a second
> object (bClass) Am getting:
>
> *Unpersistable('Unpersistable data: instance of class amodule.bClass
> deemed insecure')*
>
>
> The aClass is copyable and unjellied, the bClass is not.
>
> Here's my code:
>
> 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
>
> Is there anyway to unjelly aClass and all the objects it can contain ?
> because unjellying included object is a headache and may turn into dirty
> code ...
If you make bClass inherit from pb.Copyable and do
pb.setUnjellyableForClass(bClass, bClass) then everything should work.
Twisted knows how to do what you want, but it's refusing to do because
you haven't marked bClass as safe to pass over the wire.
--
David Ripton dripton at ripton.net
More information about the Twisted-Python
mailing list