[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/exception/browser/ Fixed bug 212.

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Jul 7 16:09:11 EDT 2004


Log message for revision 26184:
Fixed bug 212.

NotFound error views now return 404.




-=-
Modified: Zope3/trunk/src/zope/app/exception/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/configure.zcml	2004-07-07 20:09:09 UTC (rev 26183)
+++ Zope3/trunk/src/zope/app/exception/browser/configure.zcml	2004-07-07 20:09:11 UTC (rev 26184)
@@ -30,6 +30,7 @@
       name="index.html"
       permission="zope.Public"
       template="notfound.pt"
+      class=".notfound.NotFound"
       />
 
 </zope:configure>

Added: Zope3/trunk/src/zope/app/exception/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/ftests.py	2004-07-07 20:09:09 UTC (rev 26183)
+++ Zope3/trunk/src/zope/app/exception/browser/ftests.py	2004-07-07 20:09:11 UTC (rev 26184)
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# Copyright (c) 2004 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 NotFoundError
+
+$Id: ftests.py 25177 2004-06-02 13:17:31Z jim $
+"""
+import unittest
+from zope.publisher.interfaces import NotFound
+from zope.app.tests.functional import BrowserTestCase
+
+class TestNotFound(BrowserTestCase):
+
+    def testNotFound(self):
+        response = self.publish('/foobar', basic='mgr:mgrpw',
+                                handle_errors=True)
+        self.assertEqual(response.getStatus(), 404)
+        body = response.getBody()
+        self.assert_(
+            'The page that you are trying to access is not available' in body)
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(TestNotFound),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')

Added: Zope3/trunk/src/zope/app/exception/browser/notfound.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/notfound.py	2004-07-07 20:09:09 UTC (rev 26183)
+++ Zope3/trunk/src/zope/app/exception/browser/notfound.py	2004-07-07 20:09:11 UTC (rev 26184)
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2004 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.
+#
+##############################################################################
+"""NotFound Error View class.
+
+$Id$
+"""
+class NotFound(object):
+    """NotFound Error View
+
+    NotFound errors should return 404 instead of 200.
+    """
+
+    def __call__(self, *args, **kw):
+        self.request.response.setStatus(404)
+        return self.index(*args, **kw)



More information about the Zope3-Checkins mailing list