[Zope] Re: Upgrading Zope Products

Tres Seaver tseaver at zope.com
Thu Mar 24 14:10:21 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian Brinegar wrote:

| This isn't the case. Some instances of my product (those that haven't
| had properties added to them or changed) will pick up the changes, but
| not all instances.

If you are adding properties manually through the ZMI, then they will no
longer use the '_properties' map defined by the product -- they *will*,
however, have the actual attribute defined via the class (this is how
Python's attribute lookup works).

| So for example, if I initiated an object of the old version, then
| added additional properties through the ZMI, then changed the product
| code to the updated version and restarted zope the new property will
| not show up in that instance.

You can't reuse the default PropertyManager in this fashion:  either all
instances use the '_properties' map from their class (in which case,
they can be upgraded cleanly), or they are "one-offs".  If you want to
"mix and match", you need to do more work, e.g., overriding the
PropertyManager API methods to force inclusion of the version from the
class.

| Also, this does not address adding a new index which is set normally
| set during the __init__ method.

I don't know what 'index' is, but the only backwardly-compatible way to
add such an attribute is to define a "default" at class scope (e.g.,
'index = None'), and then check for that default value whenever you need
to use it, and instantiate the "real" value at that point.  I usually
use an accessor method for such purposes.


Tres.
- --
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCQxCdGqWXf00rNCgRAlI3AJ0Yn0a4lMsFSV1dAwITagGBL/s+6wCfd252
1wYEVPbpYqqpZxHK8E1vD/o=
=FFRQ
-----END PGP SIGNATURE-----


More information about the Zope mailing list