[Zope-Coders] Re: [Zope-Checkins] CVS: Zope/lib/python/ZPublisher - xmlrpc.py:1.14

Florent Guillaume fg@nuxeo.com
Fri, 30 Aug 2002 16:16:11 +0000 (UTC)


Casey Duncan  <casey@zope.com> wrote:
> Update of /cvs-repository/Zope/lib/python/ZPublisher
> In directory cvs.zope.org:/tmp/cvs-serv24443
> 
> Modified Files:
> 	xmlrpc.py 
> Log Message:
> Improved error output for xmlrpc faults
> 
>  - Value is stripped of HTML tags and minimally formatted
> +            # Strip HTML tags and format 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))
> +            else:
> +                value = '%s\n\n%s' % (t, v)
> +                

IMHO this goes to show that the error value should never have contained
HTML in the first place. I think error values should be defined as pure
text, and the HTML publishing would html_quote it as needed, and the
XMLRPC publishing would do what it deems.

Florent
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com