Dragos Chirila wrote at 2006-12-6 20:53 +0200:
>Ok, you are right, but if I do it why the ZMI is showing to me the new
>meta type for both instances? This is wrong...

You have to distinquish between attributes defined on class and those
defined on instance level.

Attributes defined on class level are not persisted. When you change
the attribute on the class, all class instances will see the change.

Attributes defined on instance level are persisted. If you later
change the value used to initialize the attribute, only newly created
instances will get this new value; old instances will retain the old

"meta_type" is usually defined on class level.
This is also the case in your situation -- as you see the value
changing, when you change the class definition.

>Also, I don't understand why if I explicit change the meta_type
>property for the old instance (e.g. a method of MyClass that is called
>via URL) still nothing happens?

If you change "meta_type" on a specific instance, then it will stick
and no longer follow any modifications in the class.
>I also tried to add the following lines to the MyClass:
>    _properties = (
>        Folder._properties
>        +
>        (
>            {'id': 'meta_type', 'type': 'string', 'mode': 'w'},
>        )
>    )
>In the Properties tab for both instances the same value is shown for
>the meta_type property.

Only after you changed the properties at least once, become the
properties instance level attributes (there might even be
an optimization that a property is not written when its value did not
change. In this case, you would need to change the properties value
in order to make it an instance attribute). Up to that point,
the default value defined on class level is used.

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to