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

Casey Duncan casey@zope.com
Fri, 30 Aug 2002 14:29:58 -0400


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

Modified Files:
	xmlrpc.py 
Log Message:
Refactored error message handling so that SimpleItem's raise_standardErrorMessage sniffs the response to see if it wants an html encoded error message or not.

If so, then standard_error_message is rendered as usual as the error value. Otherwise the error value text is passed through unchanged.

XML-RPC responses now request text/plain error format so that standard_error_message is not envoked to render the fault string. Because of this, the previous formatting code could be removed, although html tags are still stripped because error values themselves sometimes contain tags 8^/


=== Zope/lib/python/ZPublisher/xmlrpc.py 1.14 => 1.15 ===
--- Zope/lib/python/ZPublisher/xmlrpc.py:1.14	Fri Aug 30 11:15:01 2002
+++ Zope/lib/python/ZPublisher/xmlrpc.py	Fri Aug 30 14:29:56 2002
@@ -82,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
@@ -132,20 +134,17 @@
         Fault=xmlrpclib.Fault
         f=None
         try:
-            # Strip HTML tags and format the error value
+            # Strip HTML tags from the error value
             v = str(v)
-            v = re.sub(r"<br\s*/?>", "\n", v)
             remove = [r"<[^<>]*>", r"&[A-Za-z]+;"]
             for pat in remove:
                 v = re.sub(pat, " ", v)
-            v = re.sub(r"\n(?:\s*\n)+", "\n\n", v)
-                
             from Globals import DevelopmentMode
             if DevelopmentMode:
                 from traceback import format_exception
-                value = ''.join(format_exception(t, v, tb))
+                value = '\n' + ''.join(format_exception(t, v, tb))
             else:
-                value = '%s\n\n%s' % (t, v)
+                value = '%s - %s' % (t, v)
                 
             if isinstance(v, Fault):
                 f=v