Commit df1c8297 authored by Jens Vagelpohl's avatar Jens Vagelpohl

- LP #143755: Also catch TypeError when trying to determine an

  indexable value for an object in PluginIndexes.common.UnIndex
parent 4a5449cc
......@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/releases/.
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.
......
......@@ -272,7 +272,7 @@ class UnIndex(SimpleItem):
datum = getattr(obj, attr)
if safe_callable(datum):
datum = datum()
except AttributeError:
except (AttributeError, TypeError):
datum = _marker
return datum
......
......@@ -46,6 +46,34 @@ class UnIndexTests(unittest.TestCase):
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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment