[Twisted-Python] making C extension module types Copyable

Damon Fasching damon.fasching at sbcglobal.net
Mon Apr 5 23:36:23 MDT 2004


Hi,

I am attempting to set up a system around Perspective
Broker.  A large part of the data which I need to pass
around is instances of a rather complex type which I
have defined in a C extension module.  This type is
built of a deeply nested hierarchy of C structures. 
At some levels of the hierarchy, structure elements
include malloced data buffers of arbitrary size.

I was hoping for some sort of miracle (see attached
code) and, no surprises, it didn't happen :(

How do I get my class to inherit from Copyable.  (I
suspect the answer is I can't.)  If I can't, how can I
make it copyable (lowercase)?

I was hoping that by wrapping MyType in a simple
Python class, MyTypeWrapper, which does inherit from
Copyable I would be able to pass it around.  I still
get an InsecureJelly exception for MyType.  So it
seems classes need to be registered with
setCopierForClass even if they are used only as
attributes of a class which is being copied.  That
seems reasonable.  But, with a type defined in a C
extension module, I don't have a class to
setCopierFor...  Also, does MyType also need to
subclass Copyable in order to setCopierForClass for
it?  Don't think I can do that either...

The second problem is probably more serious, if that's
possible.  I can't imagine a world generous enough
where MyType instances would actually be serialized,
deserialized and reconstructed properly on the
receiving end, nested structures, malloced buffers and
all.

Can some suggest a path?  I am writing both the client
and server code and so was hoping to use Perspective
Broker.  Serializing the object by hand is going to be
a pain, but not impossible.  If that's what needs to
be done, I am still not sure how to package it for
transmission.

Thanks for your help,
  Damon





More information about the Twisted-Python mailing list