[Zope-dev] Using default values for variables in class definitions ... Is this o.k.?
Joachim Werner
joe@iuveno-net.de
Tue, 6 Nov 2001 01:46:13 +0100
Hi!
I am facing the following common problem:
Let's say I have a filesystem-based Python Zope Product that uses
propertysheets. I have defined a couple of properties and already have a
number of instances of the class.
Now I add a new property to the code. While this would not break anything if
I worked with ZClasses, the filesystem-based propertysheet implementation
will raise an error if I visit my existing instances' Properties tag because
the property is not there.
To avoid that, I have used the trick to add a default value for the new
property in the class definition:
class News(...):
meta_type = 'News'
...
myNewProperty='Green'
...
def ...
etc.
This works perfectly, but I have been told that I should not do this because
of the way ExtensionClasses work. Does anybody know more about that?
Cheers
Joachim