[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - BaseRequest.py:1.49.4.1 HTTPRequest.py:1.80.2.1 xmlrpc.py:1.12.4.1
Chris McDonough
chrism@zope.com
Tue, 3 Sep 2002 03:44:19 -0400
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv3114/lib/python/ZPublisher
Modified Files:
Tag: chrism-install-branch
BaseRequest.py HTTPRequest.py xmlrpc.py
Log Message:
Merge of head into installer-branch. Sorry. :-(
=== Zope/lib/python/ZPublisher/BaseRequest.py 1.49 => 1.49.4.1 ===
--- Zope/lib/python/ZPublisher/BaseRequest.py:1.49 Wed Aug 14 18:09:39 2002
+++ Zope/lib/python/ZPublisher/BaseRequest.py Tue Sep 3 03:43:48 2002
@@ -13,6 +13,7 @@
__version__='$Revision$'[11:-2]
from urllib import quote
+import xmlrpc
UNSPECIFIED_ROLES=''
@@ -196,7 +197,8 @@
# How did this request come in? (HTTP GET, PUT, POST, etc.)
method=req_method=request_get('REQUEST_METHOD', 'GET').upper()
- if method=='GET' or method=='POST':
+ if method=='GET' or method=='POST' and not isinstance(response,
+ xmlrpc.Response):
# Probably a browser
no_acquire_flag=0
# index_html is still the default method, only any object can
=== Zope/lib/python/ZPublisher/HTTPRequest.py 1.80 => 1.80.2.1 ===
--- Zope/lib/python/ZPublisher/HTTPRequest.py:1.80 Tue Aug 20 23:09:31 2002
+++ Zope/lib/python/ZPublisher/HTTPRequest.py Tue Sep 3 03:43:48 2002
@@ -373,7 +373,6 @@
meth, self.args = xmlrpc.parse_input(fs.value)
response=xmlrpc.response(response)
other['RESPONSE']=self.response=response
- other['REQUEST_METHOD']='' # We don't want index_html!
self.maybe_webdav_client = 0
else:
self._file=fs.file
=== Zope/lib/python/ZPublisher/xmlrpc.py 1.12 => 1.12.4.1 ===
--- Zope/lib/python/ZPublisher/xmlrpc.py:1.12 Wed Aug 14 18:09:40 2002
+++ Zope/lib/python/ZPublisher/xmlrpc.py Tue Sep 3 03:43:48 2002
@@ -19,10 +19,13 @@
information about XML-RPC and Zope.
"""
-import sys
+import re
+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
@@ -63,8 +66,6 @@
# r.__dict__.update(anHTTPResponse.__dict__)
# return r
-
-
########################################################################
# Possible implementation helpers:
@@ -81,9 +82,11 @@
It's probably possible to improve the 'exception' method quite a bit.
The current implementation, however, should suffice for now.
"""
+
+ _error_format = 'text/plain' # No html in error values
# Because we can't predict what kind of thing we're customizing,
- # we have to use delegation, rather than inheritence to do the
+ # we have to use delegation, rather than inheritance to do the
# customization.
def __init__(self, real): self.__dict__['_real']=real
@@ -120,18 +123,35 @@
if type(info) is type(()) and len(info)==3: t,v,tb = info
else: t,v,tb = sys.exc_info()
- # Create an appropriate Fault object. Unfortunately, we throw away
- # most of the debugging information. More useful error reporting is
- # left as an exercise for the reader.
+ # 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. Containing error information
Fault=xmlrpclib.Fault
f=None
try:
+ # Strip HTML tags from the error value
+ v = str(v)
+ remove = [r"<[^<>]*>", r"&[A-Za-z]+;"]
+ for pat in remove:
+ v = re.sub(pat, " ", v)
+ from Globals import DevelopmentMode
+ if DevelopmentMode:
+ from traceback import format_exception
+ value = '\n' + ''.join(format_exception(t, v, tb))
+ else:
+ value = '%s - %s' % (t, v)
+
if isinstance(v, Fault):
f=v
elif isinstance(v, Exception):
- f=Fault(-1, "Unexpected Zope exception: " + str(v))
+ f=Fault(-1, 'Unexpected Zope exception: %s' % value)
else:
- f=Fault(-2, "Unexpected Zope error value: " + str(v))
+ f=Fault(-2, 'Unexpected Zope error value: %s' % value)
except:
f=Fault(-3, "Unknown Zope fault type")