[Zope-dev] new BTreeContainer implementation, please review

Christophe Combelles ccomb at free.fr
Fri Jun 13 15:40:06 EDT 2008


Hi,

While fixing some bugs in zope.app.container,
I've also modified the implementation of the BTreeContainer,
by not inheriting from the SampleContainer, and directly accessing the btree. 
This had remained as a TODO in the btree.py file, so I did it, but...

The result is all previous persisted BTreeContainers (such as PrincipalFolder) 
are broken because the btree used to be stored in self._SampleContainer__data, 
while the new implementation stores it in self._BTreeContainer__data.

So I've added a property to offer a transparent backward compatibility:

     def _get__data(self):
         try:
             return self._BTreeContainer__data
         except:
             return self._SampleContainer__data
     def _set__data(self, value):
         try:
             self._BTreeContainer__data = value
         except:
             self._SampleContainer__data = value
     def _del_data(self):
         try:
             del self._BTreeContainer__data
         except:
             del self._SampleContainer__data
     __data = property(_get__data, _set__data, _del_data)



Do you think it is safe? Is there any better solution for this? Should I rather 
write an evolution script? Or should I revert all this back to inheriting from 
SampleContainer?

Christophe


More information about the Zope-Dev mailing list