[Zope] Upgrading Zope Products

Lennart Regebro regebro at gmail.com
Fri Mar 25 06:59:11 EST 2005


Unless the database mostly consists of records that will never again
be touched, I would suggest going through the whole database and
upgrade object.

I have found that when upgrading objects is necessary, it's a good
thing to set an __object_version__ attribute or something on the
object, to quickly check if it has been upgraded or not. This is
especially important if you don't do batch upgrading, as you don't
want to have twenty lines of code doing the upgrade each time you
access the object.

The __setstate__ kludge is typically not a good one, since the changes
aren't persisted. It's better to create an _upgrade() method on the
object, that first checks the __object_version__ and upgrades if
necessary, and then simply call this method first in all accessing
methods.  If you usually access the attributes directly before any
methods are called, you are pretty much in deep shit. ;) Then you
really have to do a "batch" upgrade.

-- 
Lennart Regebro, Nuxeo     http://www.nuxeo.com/
CPS Content Management     http://www.cps-project.org/


More information about the Zope mailing list