Hi all, I'm having a really weird problem when trying to accomplish custom error reporting. The problem is 100% utf-8 and encoding specific and only arises if the template contains accented characters. I've checked with vim and the template text files are saved in utf-8.
There are two things involved, one of them works as expected, the other one not. The thing that works: adding a nice @exception_handler( ) to a method does the expected thing even if the corresponding template has accented characters in it. The other thing that does not work is this: I'm trying to accomplish application wide custom error reporting for 401, 403, 404, etc, following http://turbogears.org/1.5/docs/ErrorReporting.html and so I add this to my controller: if config.get('error_catcher.on', False): _cp_config = { 'error_page.default': error_page, 'request.error_response': handle_error } And error_page( ) and handle_error( ) are implemented in the same way as in the above cited doc. The crucial part of the error_page( ) function is the returning of the actual rendered error page: return controllers._process_output(data, template, format, content_type, None) And this leads to trouble if the template has accented characters in it: Traceback (most recent call last): File "/home/fetch/lib/python2.7/CherryPy-3.2.4-py2.7.egg/cherrypy/_cprequest.py", line 664, in respond inst.set_response() File "/home/fetch/lib/python2.7/CherryPy-3.2.4-py2.7.egg/cherrypy/_cperror.py", line 376, in set_response message=self._message).encode('utf-8') UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 910: ordinal not in range(128) As you can see the exception is coming from cherrypy, not turbogears. In other words, @exception_handler (which is part of turbogears) goes through okay but application-wide error reporting does not (which involves cherrypy directly). I was trying to solve the problem by trying to figure out what encoding/decoding/etc trickery is done when tg creates the output from the controller methods passing it through @exception_handler but I was not able to. Clearly if I would do the same thing in my error_page( ) function it would also work in that case. Interestingly, if I run the same code on a different machine where all versions are the same, except cherrypy is 3.2.2, then everything works! I can't imagine the problem was introduced in cherrypy 3.2.4 but it could be. The versions I use: cherrypy 3.2.4 turbogears 1.5.1 kid 0.9.6 turbokid 1.0.5 Any ideas? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

