[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher - BaseRequest.py:1.1.2.15 Exceptions.py:1.1.2.9 Publish.py:1.1.2.11

Shane Hathaway shane@digicool.com
Fri, 30 Nov 2001 10:27:27 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher
In directory cvs.zope.org:/tmp/cvs-serv29399/lib/python/Zope/Publisher

Modified Files:
      Tag: Zope-3x-branch
	BaseRequest.py Exceptions.py Publish.py 
Log Message:
- Added tests of HTTP pipelining and fixed bugs.

- Added tests of publisher retry mechanisms and fixed bugs.

- Rearranged http_task for clarity.

- Moved knowledge of PATH_INFO into BaseRequest only.

- Removed commented code.

- Corrected publisher Retry handling.

All this while riding the VRE.  Gotta love trains! ;-)


=== Zope3/lib/python/Zope/Publisher/BaseRequest.py 1.1.2.14 => 1.1.2.15 ===
         self._request_default = steps
 
-##    def _getDefaultView(self, object, m_name='_browser_default'):
-##        """
-##        returns (object, add_steps)
-##        """
-##        psteps = None
-##        f = getattr(object, m_name, None)
-##        if f is not None:
-##            v = f(self)
-##            if v is not None:
-##                if type(v) is StringType:
-##                    # One more traversal step.
-##                    return object, (v,)
-##                else:
-##                    # Arbitrary additional traversal.
-##                    o, add_steps = v
-##                    if add_steps or o is not object:
-##                        return o, add_steps
-##        m = self._request_method
-##        if m == 'GET' or m == 'POST':
-##            default = 'index_html'
-##        else:
-##            default = m
-##        if default and getattr(object, default, None) is not None:
-##            return object, (default,)
-##        return object, ()
-
-
     def changeTraversalStack(self, names):
         """
         Private.  Can be called by a traversal hook.
@@ -250,12 +223,13 @@
         self.other['AUTHENTICATION_PATH'] = '/'.join(self.steps)
 
 
-    def traverse(self, publication, object, path_str):
+    def traverse(self, publication, object):
         """
         Traverses to an object and returns it.
         Private.
         """
         added_default = 0
+        path_str = self.get('PATH_INFO', '').strip()
         to_traverse = self.splitPath(path_str)
 
         self.traversed = traversed = []


=== Zope3/lib/python/Zope/Publisher/Exceptions.py 1.1.2.8 => 1.1.2.9 ===
         return self.orig_exc
 
+    def __str__(self):
+        return repr(self.orig_exc)


=== Zope3/lib/python/Zope/Publisher/Publish.py 1.1.2.10 => 1.1.2.11 ===
         publication.beforeTraversal(request)
 
-        object = publication.getApplication(request)
-        path_str = request.get('PATH_INFO', '').strip()
-        object = request.traverse(publication, object, path_str)
+        root_object = publication.getApplication(request)
+        object = request.traverse(publication, root_object)
         publication.afterTraversal(request, object)
 
         result = publication.callObject(request, object)
@@ -43,11 +42,11 @@
 
         publication.afterCall(request)
     except:
-        handleException(sys.exc_info(), request, publication, 1)
+        handleException(request, publication, sys.exc_info(), 1)
 
 
 
-def handleException(exc_info, request, publication=None, allow_retry=1):
+def handleException(request, publication, exc_info, allow_retry=1):
     if publication is not None:
         publication.handleException(request, exc_info, allow_retry)
     else:
@@ -61,23 +60,27 @@
         to_raise = None
         while 1:
             try:
-                executeRequest(request)
-                # Successful.
-                break
-            except Retry, v:
-                if request.supports_retry():
-                    # Create a copy of the request and use it.
-                    newrequest = request.retry()
-                    request.close()
-                    request = newrequest
-                else:
-                    # Output the original exception.
-                    publication = request.getPublication()
-                    handleException(v.getOriginalException(), request,
-                                    publication, 0)
+                try:
+                    executeRequest(request)
+                    # Successful.
+                    break
+                except Retry, v:
+                    if request.supports_retry():
+                        # Create a copy of the request and use it.
+                        newrequest = request.retry()
+                        request.close()
+                        request = newrequest
+                    else:
+                        # Output the original exception.
+                        publication = request.getPublication()
+                        handleException(request, publication,
+                                        v.getOriginalException(), 0)
+                        break
             except:
+                # Bad exception handler or retry method.
                 # Re-raise after outputting the response.
                 to_raise = sys.exc_info()
+                request.response.setStatus(500) # Try to indicate an error.
                 break
 
         response = request.response