[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/exception/browser/ Change the default (system error) view to return a 500 status code.

Jim Fulton jim at zope.com
Thu Oct 28 14:22:30 EDT 2004


Log message for revision 28274:
  Change the default (system error) view to return a 500 status code.
  

Changed:
  U   Zope3/trunk/src/zope/app/exception/browser/default.pt
  U   Zope3/trunk/src/zope/app/exception/browser/ftests.py
  A   Zope3/trunk/src/zope/app/exception/browser/systemerror.txt

-=-
Modified: Zope3/trunk/src/zope/app/exception/browser/default.pt
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/default.pt	2004-10-28 14:10:36 UTC (rev 28273)
+++ Zope3/trunk/src/zope/app/exception/browser/default.pt	2004-10-28 18:22:29 UTC (rev 28274)
@@ -1,5 +1,5 @@
 <html><title>System Error</title>
-<body>
+<body tal:define="ignored python:request.response.setStatus(500)">
   A system error occurred.
 </body>
 </html>

Modified: Zope3/trunk/src/zope/app/exception/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/ftests.py	2004-10-28 14:10:36 UTC (rev 28273)
+++ Zope3/trunk/src/zope/app/exception/browser/ftests.py	2004-10-28 18:22:29 UTC (rev 28274)
@@ -17,9 +17,9 @@
 """
 import unittest
 from zope.publisher.interfaces import NotFound
-from zope.app.tests.functional import BrowserTestCase
+from zope.app.tests import functional
 
-class TestNotFound(BrowserTestCase):
+class TestNotFound(functional.BrowserTestCase):
 
     def testNotFound(self):
         response = self.publish('/foobar', basic='mgr:mgrpw',
@@ -32,6 +32,7 @@
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(TestNotFound),
+        functional.FunctionalDocFileSuite('systemerror.txt'),
         ))
 
 if __name__ == '__main__':

Added: Zope3/trunk/src/zope/app/exception/browser/systemerror.txt
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/systemerror.txt	2004-10-28 14:10:36 UTC (rev 28273)
+++ Zope3/trunk/src/zope/app/exception/browser/systemerror.txt	2004-10-28 18:22:29 UTC (rev 28274)
@@ -0,0 +1,62 @@
+System Errors
+=============
+
+System Errors are errors representing a system failure.  At the
+application level, they are errors that are uncaught by the
+application and that a developer hasn't provided a custom error view
+for. 
+
+Zope provides a default system error view that prints an obnoxius
+terse message and that sets the response status.
+
+To see an example of this, we'll create a ZPT page with an intentional
+error: 
+
+  >>> print http(r"""
+  ... POST /+/zope.app.zptpage.ZPTPage%3D HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 739
+  ... Content-Type: multipart/form-data; boundary=---------------------------125598457818223697821067764270
+  ... Referer: http://localhost:8081/+/zope.app.zptpage.ZPTPage=
+  ... 
+  ... -----------------------------125598457818223697821067764270
+  ... Content-Disposition: form-data; name="field.source"
+  ... 
+  ... <html><body tal:content="container/eek" /></html>
+  ... -----------------------------125598457818223697821067764270
+  ... Content-Disposition: form-data; name="field.expand.used"
+  ... 
+  ... 
+  ... -----------------------------125598457818223697821067764270
+  ... Content-Disposition: form-data; name="field.evaluateInlineCode.used"
+  ... 
+  ... 
+  ... -----------------------------125598457818223697821067764270
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ... 
+  ... Add
+  ... -----------------------------125598457818223697821067764270
+  ... Content-Disposition: form-data; name="add_input_name"
+  ... 
+  ... test.html
+  ... -----------------------------125598457818223697821067764270--
+  ... """)
+  HTTP/1.1 303 See Other
+  ...
+  Location: http://localhost/@@contents.html
+  ...
+
+When we visit it, we get a terse error and a 500 status:
+
+We get a system error, because the problem is in the template, not in
+the URL:
+
+  >>> print http(r"""
+  ... GET /test.html HTTP/1.1
+  ... """)
+  HTTP/1.1 500 Internal Server Error
+  ...
+    A system error occurred.
+  ...
+
+



More information about the Zope3-Checkins mailing list