[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Now @@errorRedirect.html does the right thing while called from /++etc++process

Dmitry Vasiliev dima at hlabs.spb.ru
Tue Apr 12 04:26:40 EDT 2005


Log message for revision 29946:
  Now @@errorRedirect.html does the right thing while called from /++etc++process
  

Changed:
  A   Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_errorredirect.py
  U   Zope3/trunk/src/zope/app/error/browser/__init__.py

-=-
Added: Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_errorredirect.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_errorredirect.py	2005-04-11 22:20:41 UTC (rev 29945)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_errorredirect.py	2005-04-12 08:26:40 UTC (rev 29946)
@@ -0,0 +1,39 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""ZODB Control Tests
+
+$Id$
+"""
+import unittest
+
+from zope.app.testing.functional import BrowserTestCase
+
+
+class ErrorRedirectTest(BrowserTestCase):
+
+    def testErrorRedirect(self):
+        response = self.publish('/++etc++process/@@errorRedirect.html',
+                                basic='globalmgr:globalmgrpw')
+        self.failUnlessEqual('http://localhost/@@errorRedirect.html',
+                             response.getHeader('Location'))
+        self.failUnlessEqual(302, response.getStatus())
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(ErrorRedirectTest))
+    return suite
+
+if __name__=='__main__':
+    unittest.main(defaultTest='test_suite')


Property changes on: Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_errorredirect.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: Zope3/trunk/src/zope/app/error/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/error/browser/__init__.py	2005-04-11 22:20:41 UTC (rev 29945)
+++ Zope3/trunk/src/zope/app/error/browser/__init__.py	2005-04-12 08:26:40 UTC (rev 29946)
@@ -21,6 +21,7 @@
 from zope.app.error.interfaces import IErrorReportingUtility
 from zope.app.error.interfaces import ILocalErrorReportingUtility
 
+
 class EditErrorLog(object):
     __used_for__ = ILocalErrorReportingUtility
 
@@ -36,18 +37,16 @@
 class ErrorRedirect(BrowserView):
 
     def action(self):
-
-        # Some locations (eg ++site++process) throw a TypeError exception when
+        # Some locations (eg ++etc++process) throw a TypeError exception when
         # finding their absoluteurl, if this happens catch the error and
         # redirect the browser to the site root "/@@errorRedirect.html"
         # to handle redirection to the site error logger instead
         try:
             err = zapi.getUtility(IErrorReportingUtility)
             url = zapi.absoluteURL(err, self.request)
-            url = url + "/@@SelectedManagementView.html"
         except TypeError:
-            # siterooturl = self.request.getApplicationURL()
-            url = self.request.getURL(1) + "/@@SelectedManagementView.html"
+            url = self.request.getApplicationURL() + "/@@errorRedirect.html"
+        else:
+            url = url + "/@@SelectedManagementView.html"
 
         self.request.response.redirect(url)
-



More information about the Zope3-Checkins mailing list