[Zope] [Warning] "ManagableIndex" "Zope2.8+" incompatibility

Dieter Maurer dieter at handshake.de
Fri May 5 14:37:10 EDT 2006


WARNING!

We hit an incompatibility of "ManagableIndex" with "Zope 2.8+".

   For Python new style classes, "__len__" instance attributes are no
   longer taken into account
   in the implementation of the "len" builtin.
   "len" now only looks for "__len__" class attributes.

   From "Zope 2.8+" on, all persistent Zope objects
   are instances of new style classes. Especially,
   "ManagableIndex"es are new style classes.
   "ManagableIndex"'s "__len__" instance attribute
   is no longer used by "len".

   Some Zope base class defines the class method "__len__"
   to return 1.

   As a consequence, "len" applied to a "ManagableIndex"
   always returns 1 in Zope 2.8 and later (until "ManagableIndex 1.3.1").


The badly behaving "len" can seriously confuse "AdvancedQuery"
(and other similar query frameworks) that uses "len(index)" to
guide the implementation of sorting.

In our observed case, "AdvancedQuery" sorting was 3 to 5 times
slower and read 3 times more objects than necessary.


The bug is fixed in "ManagableIndex 1.3.1".


Download

  <http://www.dieter.handshake.de/pyprojects/zope>




-- 
Dieter


More information about the Zope mailing list