[ZODB-Dev] Migration of obsolete BTrees to ZOPE 2.8
Dieter Maurer
dieter at handshake.de
Fri Nov 18 14:38:23 EST 2005
Tim Peters wrote at 2005-11-18 10:02 -0500:
>[Margie Watkins CONT]
>> The issue http://www.zope.org/Collectors/Zope/1695 asks for a statement
>> from users who are affected by the missing modules.
>
>Unfortunately, that's become "out of sight, out of mind" since then -- the
>issue was opened 9 months ago, and to date you're the first to say you
>really need this (if you read through all the referenced threads, you'll see
>that everyone else who thought they _might_ need it eventually discovered
>that they did not).
It is no problem as long as you migrate while you are still
using a Zope 2.7 (ZODB 3.2) release.
We added automatic migration code to our old "BTree/Intset" using code.
But we may need an explicit conversion before we finally upgrade
to Zope 2.8 -- to get very rarely used objects upgraded as well.
> ...
>I'm not sure to what that refers, but not sure it matters either. There are
>four threads referenced in the bug report, and AFAICT none of them claim to
>present a migration method for "old" BTrees or intSets.
The migration is trivial as long as "BTree" and "Intset" are still
available. We use for example the following "BTree" migration.
# backward (pre Zope 2.8) compatibility
try:
from BTree import BTree as _BTreeOld
# DM 2005-08-25: for unknown reasons, this can raise an "AttributeError"
# rather than an "ImportError"
#except ImportError: _BTreeOld = None
except (ImportError, AttributeError): _BTreeOld = None
from BTrees.OOBTree import OOBTree as BTree
...
tree = self._tree
if _BTreeOld is not None and isinstance(tree, _BTreeOld):
# still an oldy -- upgrade to modern structure
self._tree = BTree(tree)
msg = 'BTree upgraded'
else: msg = 'BTree was already modern'
--
Dieter
More information about the ZODB-Dev
mailing list