<div dir="ltr">I didnt make bClass as copyable and unjellyed it just for the question, in fact, the example i gave was the bare minimum of my source code to let people clearly view the issue.<div><br></div><div>In the real problem, aClass has many references to other objects and if i were to set them all as copyable and then unjellyed them all on the server side, that would be a headache ...</div>
<div><br></div><div>Am asking whether if a clean solution exist for such problems.<br>
<br><br><div class="gmail_quote">On Sun, Jan 29, 2012 at 7:11 AM, David Ripton <span dir="ltr"><<a href="mailto:dripton@ripton.net">dripton@ripton.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 01/29/12 00:57, Fourat ZOUARI wrote:<br>
<br>
> Whenever i try to pass an object (aClass) with a property with a second<br>
> object (bClass) Am getting:<br>
><br>
</div>> *Unpersistable('Unpersistable data: instance of class amodule.bClass<br>
> deemed insecure')*<br>
<div><div class="h5">><br>
><br>
> The aClass is copyable and unjellied, the bClass is not.<br>
><br>
> Here's my code:<br>
><br>
> server.py:<br>
><br>
> from twisted.application import internet, service<br>
> from twisted.spread import pb<br>
> from amodule import PBServer<br>
><br>
> application = service.Application("Test app")<br>
><br>
> # Prepare managers<br>
> clientManager = internet.TCPServer(8282,<br>
> pb.PBServerFactory(PBServer()));<br>
> clientManager.setServiceParent(application)<br>
><br>
> if __name__ == '__main__':<br>
> print "Run with twistd"<br>
> import sys<br>
> sys.exit(1)<br>
><br>
><br>
> amodule.py:<br>
><br>
> from twisted.spread import pb<br>
><br>
> class bClass:<br>
> """This is not a Copyable class<br>
> """<br>
><br>
> class aClass(pb.RemoteCopy, pb.Copyable):<br>
> b = bClass()<br>
> pb.setUnjellyableForClass(aClass, aClass)<br>
><br>
> class PBServer(pb.Root):<br>
> def remote_echo(self, a):<br>
> return a.b<br>
><br>
> Is there anyway to unjelly aClass and all the objects it can contain ?<br>
> because unjellying included object is a headache and may turn into dirty<br>
> code ...<br>
<br>
</div></div>If you make bClass inherit from pb.Copyable and do<br>
pb.setUnjellyableForClass(bClass, bClass) then everything should work.<br>
<br>
Twisted knows how to do what you want, but it's refusing to do because<br>
you haven't marked bClass as safe to pass over the wire.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
David Ripton <a href="mailto:dripton@ripton.net">dripton@ripton.net</a><br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</font></span></blockquote></div><br></div></div>