using cp.3.0.2
After handling all the request-parameter decoding by myself
(never
sure I got it right), I checked out tools.decode.
1) It seems like this tool expects as parameters only
strings and
lists of strings. But I'm using the routes-dispatcher wich
defaults
some parameters to "None" for example. The tool
tries to decode that
"None" - bang.
2) Another problem seems to be, that params allready in
unicode form
are not passed further.
I have modified the subroutine decode_params of the decode
tool which
reflects this.
def decode_params(encoding):
decoded_params = {}
for key, value in cherrypy.request.params.items():
if hasattr(value, 'file'):
# This is a file being uploaded: skip it
decoded_params[key] = value
elif isinstance(value, list):
# value is a list: decode each element
decoded_params[key] = [v.decode(encoding) for v
in value]
elif isinstance(value, unicode):
#dirk: keep unicode param (move this to else
decoded_params[key] = value
elif isinstance(value, str):
# value is a regular string: decode it
decoded_params[key] = value.decode(encoding)
else:
# dirk: value is something else (maybe modified
by a
custom dispatcher)
# keep it
decoded_params[key] = value
# Decode all or nothing, so we can try again on error.
cherrypy.request.params = decoded_params
dirk
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|