[Zope] Class - Object relationship

Lennart Regebro lennart@regebro.nu
Sat, 8 Dec 2001 14:45:34 +0100


From: "Tom Cameron" <tom@mooball.com>
> I would like to know how an object/instance "knows" what class it is built
> from.

There is no general answer to that, it depends on what environment you are
talking about. C++, Python, ZODB...

> How much of a python product can I change before the instances of that
> product no-longer know that they are instances of that product? Is is just
> the meta_type? What if I create two products with the same meta_type?

Thats quite possible, but confusing. Youst copy a product directory to
another  product directory and restart the server to see what happens.
Usually you get TWO listings of the product objects in the add box!

So the class name is the fully qualified name of the class. I.e. OFS.Folder,
or Product.ZCatalog.ZCatalog.

Version handling of objects is not trivial, and I don't have much experience
of it, but if you want it, I'd imagine this to be a useable way to go:

In __init__ of a class, set self._version to the version of the class. Each
time the internal structure changes, you need to upgrade the object, which
can be done in __setstate__ I think. Check the version, to the upgrade and
then again set _version to the new version number.

I SHOULD start doing this on all my objects, but i'm too lazy. :-)
If anybody have better ideas when it comes to object version management I'm
all ears! :-)