[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #143755: Also catch TypeError when trying to determine an

Jens Vagelpohl jens at dataflake.org
Wed Jul 14 10:53:25 EDT 2010


Log message for revision 114746:
  - LP #143755: Also catch TypeError when trying to determine an
    indexable value for an object in PluginIndexes.common.UnIndex
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py
  U   Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2010-07-14 14:37:25 UTC (rev 114745)
+++ Zope/branches/2.12/doc/CHANGES.rst	2010-07-14 14:53:25 UTC (rev 114746)
@@ -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/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py
===================================================================
--- Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py	2010-07-14 14:37:25 UTC (rev 114745)
+++ Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py	2010-07-14 14:53:25 UTC (rev 114746)
@@ -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/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py
===================================================================
--- Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py	2010-07-14 14:37:25 UTC (rev 114745)
+++ Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py	2010-07-14 14:53:25 UTC (rev 114746)
@@ -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