[Zope-dev] standard_error_message and displaying non-html content.

Noel Duffy noel.duffy@propylon.com
Wed, 17 Oct 2001 14:51:24 +0100


I have a zope site where users can access content using either html
browsers and non-html devices, wap/wml, voicexml etc. I want to
customize the standard_error_message dtml document to display errors
in the appropriate format for each user. For example, if a user tries
to access a non-existent url from a wml browser, they should get a
nice wml page back saying that the page was not found.

Heres the problem. Although I have customized standard_error_message
to display a page in the right format, the code in
ZPublisher/HTTPResponse.py (exception method of HTTPResponse class)
checks the error page I generate and, if it doesn't see "<html>" or
"<!doctype html" at the start of the page, it wraps my page in some
html by calling _error_html. Thus I get a small wml page wrapped in
html :-( It makes no difference what the content-type header is set to
- I'm setting that correctly for the users browser.

Is there any clean way I can alter this behaviour short of changing
the code in ZPublisher/HTTPResponse.py? I say clean because I
did find a rather ugly hack that will work - it involves replacing
a method of the RESPONSE object at run-time. Not nice!

Thanks in advance

Noel Duffy.


-- 
Noel Duffy
Senior Software Engineer
www.propylon.com
Tel: +353 96 36038 Fax: +353 96 36353