[Twisted-Python] Problems with PB and Jelly...

Sean Riley sean at twistedmatrix.com
Wed Mar 19 22:01:58 EST 2003

The "Module not allowed" exception means that you need to call
setCopierForClass for the class. This maps a server-side class string to a
client side class so the Jelly knows what type of object to create on the
client.  For example:

pb.setCopierForClass('MyApp.game.server.door.Door', RemoteDoor)

This is usually done at the bottom of the file that the class client-side is
defined in.

As far the inheritance, you should only to inherit from RemoteCopy for
client side objects, not both pb.Copyable and pb.RemoteCopy...

The "setCopyableState" idiom for constructing remote classes may seem
onerous at first, but its use really is necessary. Distributed objects _are_
different from regular local objects and the requirements for managing them
are different too. One of the benefits of PB is its inherent security
model - it is far more secure and resistant to hackery than using Pickle.
Pickle's internal use of Python's eval function makes it very scary to
unserialized Pickled objects on a server...

-----Original Message-----
From: twisted-python-admin at twistedmatrix.com
[mailto:twisted-python-admin at twistedmatrix.com]On Behalf Of Jasper
Sent: Wednesday, March 19, 2003 6:04 PM
To: twisted-python at twistedmatrix.com
Subject: [Twisted-Python] Problems with PB and Jelly...

Hash: SHA1

I'm new to twisted, and attempting to use it for networkable gaming;
unfortunately I've run into some problems.

I have a Perspective <-> Referenceable server/client setup, and am trying to
pass objects between them.  Following the online docs I've set all the
relavent classes to inherit from pb.Copyable + pb.RemoteCopy, and passed
all to pb.setUnjellyableForClass.

However, I still get "Module not allowed" exceptions raised in
twisted.spread.jelly.py line 523.  Looking more closely, I see that modules
are not allowed unless passed to SecurityOptions.allowModules(), which is
only called from SecurityOptions.allowInstancesOf(), which is not exposed
through pb...

In short I don't see how the example code on:
could possibly work!  Is it indeed necessary to call allowInstancesOf()
directly?  Hopefully I am just missing something... :-)

I'm also unsure what to make of the last bullet under "Things To Watch Out
For" on the above webpage.  It seems unsure whether using __init__ to
initialize transferable objects is ok...  Must I truly go and hack all
my objects to not use __init__, and instead use setCopyableState()?

This, especially when combined with the need to inherit from pb.Copyable +
pb.RemoteCopy, seems onerous when compared to the minimal interface of
pickle.  I would like to be able to simple pass objects of arbitrary
provided I've registered them as UnJellyable.  Hopefully I'm missing
something here as well!

Thanks in advance,
- -Jasper

Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org


Twisted-Python mailing list
Twisted-Python at twistedmatrix.com

More information about the Twisted-Python mailing list