[Zope] ExtenssionClasses Question: (was: Python Question: Morphing Classes?

Dieter Maurer dieter@handshake.de
Tue, 10 Dec 2002 20:08:56 +0100


Johan Carlsson [EasyPublisher] writes:
 > At 23:57 2002-12-09 +0100, Johan Carlsson [EasyPublisher] wrote:
 > >Creating an instance (a) of the class C: pass, I can set the
 > >a.__class__=A (where A is another class), a will report that it
 > >is a instance of A and it will have all of A's class context.
 > >
 > >This look like a possible, even if not so less hackerish, way around my 
 > >problem.
 > >
 > >Are there any traps I could fall into here?
 > 
 > I just found an even better (or at least more working way) to do this:
 > 
 > obj = new.instance(Class, Dict)
 > 
 > The problem is that new.instance doesn't seam to work with Extension Classes?
Indeed.

Use "__basicnew__" for this.
Have a look at "pickle.load" to learn how it is used.


Dieter