[Zope-Checkins] SVN: Zope/branches/2.10/ Launchpad #213311: Handle
"unsubscriptable object" errors during publishing
Tres Seaver
tseaver at palladion.com
Mon Apr 28 17:02:06 EDT 2008
Log message for revision 85832:
Launchpad #213311: Handle "unsubscriptable object" errors during publishing
traversal.
Changed:
U Zope/branches/2.10/doc/CHANGES.txt
U Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py
U Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py
-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt 2008-04-28 20:45:12 UTC (rev 85831)
+++ Zope/branches/2.10/doc/CHANGES.txt 2008-04-28 21:02:02 UTC (rev 85832)
@@ -8,6 +8,9 @@
Bugs fixed
+ - Launchpad #213311: Handle "unsubscriptable object" errors
+ during publishing traversal.
+
- Launchpad #143813: zopectl now exits non-zero when
child processes fail.
Modified: Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py 2008-04-28 20:45:12 UTC (rev 85831)
+++ Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py 2008-04-28 21:02:02 UTC (rev 85832)
@@ -121,7 +121,10 @@
pass
# Lastly we try with key access:
- subobject = object[name]
+ try:
+ subobject = object[name]
+ except TypeError: # unsubscriptable
+ raise KeyError(name)
# Ensure that the object has a docstring, or that the parent
Modified: Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py 2008-04-28 20:45:12 UTC (rev 85831)
+++ Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py 2008-04-28 21:02:02 UTC (rev 85832)
@@ -244,7 +244,16 @@
r._hold(lambda x: None)
self.assertEqual(r._held, None)
+ def test_traverse_unsubscriptable(self):
+ # See https://bugs.launchpad.net/bugs/213311
+ from ZPublisher import NotFound
+ class _Object(object):
+ pass
+ root = _Object()
+ r = self._makeOne(None)
+ self.assertRaises(NotFound, r.traverse, 'not_found')
+
class TestBaseRequestZope3Views(unittest.TestCase):
def _getTargetClass(self):
More information about the Zope-Checkins
mailing list