Suppose I have this (minimal) controller:
class Root(controllers.RootController):
@expose()
def test(self, *args, **kwargs):
return "bla"
@expose()
@identity.require(identity.not_anonymous())
def test2(self, *args, **kwargs):
return "bla2"
When I call /test?a=ä, all works as expected.
But when I call the second handler /test2?a=ä, I get an internal server error.
Note: This problem only seems to occur when the user actually is anonymous.
500 Internal error
[..]
File "[..]python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\filters\decodingfilter.py", line 50, in decode
decodedParams[key] = value.decode(enc)
File "[..]python25\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 0: ordinal not in range(128)
A possibly related problem occurs when calling the handler with "nested" query parameters:
/test2?a.b=b
500 Internal error
The server encountered an unexpected condition which prevented it from
fulfilling the request.
Traceback (most recent call last):
File "c:\programme\python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\_cphttptools.py", line 103, in _run
applyFilters('before_main')
File "c:\programme\python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\filters\__init__.py", line 151, in applyFilters
method()
File "c:\programme\python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\filters\decodingfilter.py", line 31, in before_main
self.decode(enc)
File "c:\programme\python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\filters\decodingfilter.py", line 50, in decode
decodedParams[key] = value.decode(enc)
AttributeError: 'dict' object has no attribute 'decode'
The full test project (actually, only the controllers.py has been
modified after the quickstart) is attached. It has been tested (only) with TG 1.0.4b2.