[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - ZopePublication.py:1.1.2.21

Shane Hathaway shane@digicool.com
Mon, 7 Jan 2002 10:46:22 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv1925/lib/python/Zope/App/ZopePublication

Modified Files:
      Tag: Zope-3x-branch
	ZopePublication.py 
Log Message:
Fixed Unauthorized clause (it wasn't returning like it should, since
this handleException() is supposed to delegate to exactly one exception
handler) and stopped returning unused information.


=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.20 => 1.1.2.21 ===
         get_transaction().abort()
 
-        t, v = exc_info[:2]
-        # XXX This leaks exc_info...
+        # XXX This does not leak exc_info, but the reason it doesn't
+        # is not easy to explain and potentially brittle,
+        # so maybe it's not a good idea to not pass exc_info
+        # to this method.  Maybe we should render the traceback first.
+        v = exc_info[1]
 
         # Delegate Unauthorized errors to the authentication service
+        # XXX Is this the right way to handle Unauthorized?  We need
+        # to understand this better.
         if isinstance(v, Unauthorized):
             sm = getSecurityManager()
             id = sm.getPrincipal()
             prin_reg.unauthorized(id, request) # May issue challenge
+            return
 
         # Look for a component to handle the exception.
         traversed = request.traversed
         if traversed:
             context = traversed[-1]
-            #handler = getExceptionHandler(context, t, request.ptype)
+            #handler = getExceptionHandler(context, t, IBrowserPublisher)
             handler = None  # no getExceptionHandler() exists yet.
             if handler is not None:
                 handler(request, exc_info)
-                return request.response
+                return
 
-        # Handle special exception types.
-        if isinstance(t, ClassType):
-            if retry_allowed and issubclass(t, ConflictError):
-                LOG('Zope Publication', INFO,
-                    'Competing writes at %s' % request.get('PATH_INFO', '???'),
-                    error=sys.exc_info())
-                raise Retry
+        # Convert ConflictErrors to Retry exceptions.
+        if retry_allowed and isinstance(v, ConflictError):
+            LOG('Zope Publication', INFO,
+                'Competing writes/reads at %s'
+                % request.get('PATH_INFO', '???'),
+                error=sys.exc_info())
+            raise Retry
 
         # Let the response handle it as best it can.
         response = request.response
         response.handleException(exc_info)
-        return response
+        return
 
 
 from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher