[Zope3-checkins] SVN: Zope3/trunk/src/zope/traversing/ - fix for issue 399: return 404 (not found) when traversing a skin fails

Christian Theune cvs-admin at zope.org
Fri Jun 16 23:24:14 EDT 2006


Log message for revision 68698:
   - fix for issue 399: return 404 (not found) when traversing a skin fails
  

Changed:
  A   Zope3/trunk/src/zope/traversing/ftests/test_skin.py
  U   Zope3/trunk/src/zope/traversing/namespace.py
  U   Zope3/trunk/src/zope/traversing/tests/test_skin.py

-=-
Added: Zope3/trunk/src/zope/traversing/ftests/test_skin.py
===================================================================
--- Zope3/trunk/src/zope/traversing/ftests/test_skin.py	2006-06-17 02:36:17 UTC (rev 68697)
+++ Zope3/trunk/src/zope/traversing/ftests/test_skin.py	2006-06-17 03:24:10 UTC (rev 68698)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Functional tests for skin traversing
+
+$Id$
+"""
+import unittest
+from zope.app.testing import functional
+from zope.publisher.interfaces import NotFound
+
+class TestSkin(functional.BrowserTestCase):
+
+    def test_missing_skin(self):
+        self.assertRaises(NotFound, self.publish, "/++skin++missingskin")
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TestSkin))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main()


Property changes on: Zope3/trunk/src/zope/traversing/ftests/test_skin.py
___________________________________________________________________
Name: svn:keywords
   + Id Rev Date
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/traversing/namespace.py
===================================================================
--- Zope3/trunk/src/zope/traversing/namespace.py	2006-06-17 02:36:17 UTC (rev 68697)
+++ Zope3/trunk/src/zope/traversing/namespace.py	2006-06-17 03:24:10 UTC (rev 68698)
@@ -362,7 +362,10 @@
 
     def traverse(self, name, ignored):
         self.request.shiftNameToApplication()
-        skin = zope.component.getUtility(IBrowserSkinType, name)
+        try:
+            skin = zope.component.getUtility(IBrowserSkinType, name)
+        except ComponentLookupError:
+            raise TraversalError("++skin++%s" % name)
         applySkin(self.request, skin)
         return self.context
 

Modified: Zope3/trunk/src/zope/traversing/tests/test_skin.py
===================================================================
--- Zope3/trunk/src/zope/traversing/tests/test_skin.py	2006-06-17 02:36:17 UTC (rev 68697)
+++ Zope3/trunk/src/zope/traversing/tests/test_skin.py	2006-06-17 03:24:10 UTC (rev 68698)
@@ -47,6 +47,14 @@
         self.assert_(IFoo.providedBy(request))
         self.assertEqual(request.shifted, 1)
 
+    def test_missing_skin(self):
+        from zope.traversing.namespace import skin
+        from zope.traversing.interfaces import TraversalError
+        request = FauxRequest()
+        ob = object()
+        traverser = skin(ob, request)
+        self.assertRaises(TraversalError, traverser.traverse, 'bar', ())
+
 def test_suite():
     return makeSuite(Test)
 



More information about the Zope3-Checkins mailing list