[Zope] Zope (X)3 FAQ

Johan Carlsson [EasyPublisher] johanc@easypublisher.com
Mon, 07 Apr 2003 13:21:15 +0000


At 10:01 2003-04-07 +0200, Lennart Regebro said:
>Thomas Guettler wrote:
>>I know. __setstate__ is what I called "implicit update". But AFAIK
>>objects which are already in memory don't get updated until the next
>>time they get unpickeled. That's why I prefere a explicit update. I
>>called this method refresh() in my python product.


>Like this:
>
>security.declarePrivate('Upgrade Objets', 'UpgradeObjectVersion')
>def UpgradeObjectVersion(self):
>     """Upgrades the object to new versions"""
>
>     # Check if upgrade is necessary:
>     if hasattr(self, '_object_version') and \
>        self._object_version == '1.1':
>         return 0 #No upgrade

I think it should use a float instead of a string because it would make it
easier to identify the occurrence of an older version than X.X.

Integers would work as well, but I have actually change the Easy
Publisher upgrade method to use a float, so float is preferred for me ;-)
(The integer part of the float represents the main version number and the 
fraction represents
the minor version (I know it will be difficult because of the three version 
standard if the second or
third digit become greater that 9, I have solved it by never letting them 
be greater that 9).

Floats are easier than tuples, I like it easy ;-)

Now days I also return a tuple with: (upgrade_needed_flag, message_list)

message_list is a list of strings that will be outputted by the Easy 
Publisher Upgrade Report Engine.

When upgrading a object it usually happens that a lot of things needs to be 
done.
For instance upgrading a Catalog you want to upgrade Indexes and Vocabularies
and it's allot easier to do from the Catalog object because you need to 
delete and add object to
the catalog.
You still want to output what's been done to the log.

Best Regards,
Johan Carlsson



-- 
Easy Publisher Developers Team
Johan Carlsson
johanc@easypublisher.com

Mail:
Birkagatan 9
SE-113 36  Stockholm
Sweden

Phone +46-(0)8-31 24 94
Fax +46-(0)8-675 04 44
Mobil +46-(0)70-558 25 24
http://www.easypublisher.com