[Twisted-Python] Transporting pb.Copyable classes?

Jasper Phillips jasper at peak.org
Tue Apr 20 20:48:00 EDT 2004

On Wed, 21 Apr 2004, Andrew Bennetts wrote:

> On Tue, Apr 20, 2004 at 04:20:32PM -0700, Jasper Phillips wrote:
> > 
> > I've been passing around instances of pb.Copyable classes for some time,
> > registering them via pb.setCopierForClassTree()...  However, this doesn't
> > allow me to pass the classes themselves.
> > 
> > I dug around in jelly and found jelly.globalSecurity.allowInstancesOf(),
> > which seems to do what I want, but makes me nervious as it's pretty
> > buried...
> > 
> > Passing classes seems like a reasonable thing to do, but now I wonder if
> > there is some reason that jelly doesn't allow it (except via a buried
> > method call)?  Or is this just an accidental misfeature?
> Why not just pass the name of the class, and unserialise that as
> appropriate?
> I'm not a PB expert (or even close), but I always lean towards passing data
> rather than code (or code-like things like classes) over remote method calls
> when I can :)

That's certainly feasible, but then I have an extra unserialize step
cluttering my code as the classes passed have attributes I want to access.
In general I'm passing game state which exists naturally as code, and while
I could always serialize and unserialize it, why bother if I don't have to?

Plus, isn't unserializing classes based upon their name exactly what jelly

On the other hand it's debateable whether the things I'm passing _should_ be
classes at all (they represent a type of terrain, with statically accessible
fields describing their game effects).  However, the quality of my code is
really a seperate issue.


More information about the Twisted-Python mailing list