Log message for revision 97521: empty object managers were evaluating to boolean false since Hanno fully implemented IContainer, because boolean checks fall through to __len__ if __nonzero__ is not implemented. always evaluating to true is the backwards-compatible approach
Changed: U Zope/trunk/doc/CHANGES.rst U Zope/trunk/src/OFS/ObjectManager.py U Zope/trunk/src/OFS/tests/testObjectManager.py -=- Modified: Zope/trunk/doc/CHANGES.rst =================================================================== --- Zope/trunk/doc/CHANGES.rst 2009-03-05 07:49:18 UTC (rev 97520) +++ Zope/trunk/doc/CHANGES.rst 2009-03-05 07:52:06 UTC (rev 97521) @@ -32,7 +32,11 @@ newer versions of the dependencies. This kind of KGS information needs to be expressed in a different way. +Bugs Fixed +++++++++++ +- Object managers should evaluate to True in a boolean test. + 2.12.0a1 (2009-02-26) --------------------- Modified: Zope/trunk/src/OFS/ObjectManager.py =================================================================== --- Zope/trunk/src/OFS/ObjectManager.py 2009-03-05 07:49:18 UTC (rev 97520) +++ Zope/trunk/src/OFS/ObjectManager.py 2009-03-05 07:52:06 UTC (rev 97521) @@ -789,6 +789,9 @@ def __len__(self): return len(self.objectIds()) + def __nonzero__(self): + return True + security.declareProtected(access_contents_information, 'get') def get(self, key, default=None): return self._getOb(key, default) Modified: Zope/trunk/src/OFS/tests/testObjectManager.py =================================================================== --- Zope/trunk/src/OFS/tests/testObjectManager.py 2009-03-05 07:49:18 UTC (rev 97520) +++ Zope/trunk/src/OFS/tests/testObjectManager.py 2009-03-05 07:52:06 UTC (rev 97521) @@ -379,6 +379,10 @@ om['2'] = si2 self.failUnless(len(om) == 2) + def test_nonzero(self): + om = self._makeOne() + self.failUnless(om) + def test_get(self): om = self._makeOne() si1 = SimpleItem('1') _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins