[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #143564: Request.resolve_url did not correctly re-raise

Jens Vagelpohl jens at dataflake.org
Wed Jul 14 07:35:58 EDT 2010


Log message for revision 114736:
  - LP #143564: Request.resolve_url did not correctly re-raise
    exceptions encountered during path traversal.
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2010-07-14 10:02:06 UTC (rev 114735)
+++ Zope/branches/2.12/doc/CHANGES.rst	2010-07-14 11:35:57 UTC (rev 114736)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++++++++++
 
+- LP #143564: Request.resolve_url did not correctly re-raise 
+  exceptions encountered during path traversal.
+
 - LP #143273: Enable the dtml-var modifiers url_quote, url_unquote, 
   url_quote_plus and url_unquote_plus to handle unicode strings.
 

Modified: Zope/branches/2.12/src/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.12/src/ZPublisher/HTTPRequest.py	2010-07-14 10:02:06 UTC (rev 114735)
+++ Zope/branches/2.12/src/ZPublisher/HTTPRequest.py	2010-07-14 11:35:57 UTC (rev 114736)
@@ -1178,7 +1178,7 @@
             rsp.exception()
         if object is None:
             req.clear()
-            raise rsp.errmsg, sys.exc_info()[1]
+            raise sys.exc_info()[0], rsp.errmsg
 
         # The traversal machinery may return a "default object"
         # like an index_html document. This is not appropriate

Modified: Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py
===================================================================
--- Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py	2010-07-14 10:02:06 UTC (rev 114735)
+++ Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py	2010-07-14 11:35:57 UTC (rev 114736)
@@ -19,6 +19,7 @@
 
     def _makeOne(self, stdin=None, environ=None, response=None, clean=1):
         from StringIO import StringIO
+        from ZPublisher import NotFound
         if stdin is None:
             stdin = StringIO()
 
@@ -37,7 +38,15 @@
         if response is None:
             class _FauxResponse(object):
                 _auth = None
+                debug_mode = False
+                errmsg = 'OK'
 
+                def notFoundError(self, message):
+                    raise NotFound, message
+
+                def exception(self, *args, **kw):
+                    pass
+
             response = _FauxResponse()
 
         return self._getTargetClass()(stdin, environ, response, clean)
@@ -995,6 +1004,16 @@
         self.failIf(len(events),
             "HTTPRequest.resolve_url should not emit events")
 
+    def test_resolve_url_errorhandling(self):
+        # Check that resolve_url really raises the same error
+        # it received from ZPublisher.BaseRequest.traverse
+        from zExceptions import NotFound
+        request = self._makeOne()
+        request['PARENTS'] = [object()]
+        self.assertRaises( NotFound
+                         , request.resolve_url
+                         , request.script + '/does_not_exist'
+                         )
 
     def test_parses_json_cookies(self):
         # https://bugs.launchpad.net/zope2/+bug/563229



More information about the Zope-Checkins mailing list