[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - xmlrpc.py:1.13

Martijn Pieters mj@zope.com
Thu, 29 Aug 2002 12:12:02 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv8700/ZPublisher

Modified Files:
	xmlrpc.py 
Log Message:
Don't mask authorization exceptions for XML-RPC calls, slightly modified
patch from Brad Clements (fixes Zope Collector issue #525).


=== Zope/lib/python/ZPublisher/xmlrpc.py 1.12 => 1.13 ===
--- Zope/lib/python/ZPublisher/xmlrpc.py:1.12	Wed Aug 14 18:09:40 2002
+++ Zope/lib/python/ZPublisher/xmlrpc.py	Thu Aug 29 12:12:01 2002
@@ -19,10 +19,12 @@
 information about XML-RPC and Zope.
 """
 
-import sys
+import sys, types
 from HTTPResponse import HTTPResponse
 import xmlrpclib
 
+from zExceptions import Unauthorized
+
 def parse_input(data):
     """Parse input data and return a method path and argument tuple
 
@@ -119,6 +121,13 @@
         # traceback object.
         if type(info) is type(()) and len(info)==3: t,v,tb = info
         else: t,v,tb = sys.exc_info()
+
+        # Don't mask 404 respnses, as some XML-RPC libraries rely on the HTTP
+        # mechanisms for detecting when authentication is required. Fixes Zope
+        # Collector issue 525.
+        if t == 'Unauthorized' or (isinstance(t, types.ClassType)
+                                   and issubclass(t, Unauthorized)):
+            return self._real.exception(fatal=fatal, info=info)
 
         # Create an appropriate Fault object. Unfortunately, we throw away
         # most of the debugging information. More useful error reporting is