[Zope] adding method to class after object creation

Dieter Maurer dieter at handshake.de
Tue Aug 19 23:13:11 EDT 2003


Ruslan Spivak wrote at 2003-8-19 10:24 +0300:
 > Can anybody help me with the following question:
 > I havbe created zope/cmf product(e.g. LocalizedDocument) with class. 
 > User have created about 40 instances of that class in different places 
 > in zope tree. I need to add some methods to class, but how can i apply 
 > those changes(new methods) to already created objects?

This is not necessary.

Unlike JavaScript, a class in Python is not a blueprint for
object creation. Instead, each object contains a reference to
its class. When you look up an attribute, the look up
is done first in the object and then (if its fails) in its class.

Therefore, when you add attributes to a class, all objects
see them automatically (unless, they themselves have
defined attributes of the same name).


Dieter



More information about the Zope mailing list