[Zope-Checkins] SVN: Zope/trunk/ - LP #143755: Also catch TypeError when trying to determine an
Jens Vagelpohl
jens at dataflake.org
Wed Jul 14 10:56:14 EDT 2010
Log message for revision 114747:
- LP #143755: Also catch TypeError when trying to determine an
indexable value for an object in PluginIndexes.common.UnIndex
Changed:
U Zope/trunk/doc/CHANGES.rst
U Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py
U Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py
-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst 2010-07-14 14:53:25 UTC (rev 114746)
+++ Zope/trunk/doc/CHANGES.rst 2010-07-14 14:56:13 UTC (rev 114747)
@@ -11,6 +11,9 @@
Bugs Fixed
++++++++++
+- LP #143755: Also catch TypeError when trying to determine an
+ indexable value for an object in PluginIndexes.common.UnIndex
+
- LP #143533: Instead of showing "0.0.0.0" as server name when no
specific listening IP is configured for the HTTP server, do a
socket lookup to show the current server's fully qualified name.
Modified: Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py
===================================================================
--- Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py 2010-07-14 14:53:25 UTC (rev 114746)
+++ Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py 2010-07-14 14:56:13 UTC (rev 114747)
@@ -272,7 +272,7 @@
datum = getattr(obj, attr)
if safe_callable(datum):
datum = datum()
- except AttributeError:
+ except (AttributeError, TypeError):
datum = _marker
return datum
Modified: Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py
===================================================================
--- Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py 2010-07-14 14:53:25 UTC (rev 114746)
+++ Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py 2010-07-14 14:56:13 UTC (rev 114747)
@@ -46,6 +46,34 @@
self.assertRaises(ConflictError, unindex.removeForwardIndexEntry,
'conflicts', 42)
+ def test_get_object_datum(self):
+ from Products.PluginIndexes.common.UnIndex import _marker
+ idx = self._makeOne('interesting')
+
+ dummy = object()
+ self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+ class DummyContent2(object):
+ interesting = 'GOT IT'
+ dummy = DummyContent2()
+ self.assertEquals(idx._get_object_datum(dummy, 'interesting'), 'GOT IT')
+
+ class DummyContent3(object):
+ exc = None
+ def interesting(self):
+ if self.exc:
+ raise self.exc
+ return 'GOT IT'
+ dummy = DummyContent3()
+ self.assertEquals(idx._get_object_datum(dummy, 'interesting'), 'GOT IT')
+
+ dummy.exc = AttributeError
+ self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+ dummy.exc = TypeError
+ self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(UnIndexTests))
More information about the Zope-Checkins
mailing list