Ticket #590 (defect)
Opened 2 years ago
Last modified 2 years ago
dict in request parameters are not parsed
Status: closed (invalid)
| Reported by: | jhb | Assigned to: | fumanchu |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | CherryPy code | Keywords: | request |
| Cc: |
when a dict is passed in a a request parameter, cherrypy throws an
AttributeError?: 'dict' object has no attribute 'decode'
see:
Here is our solution:
#--------------8<------------------------- def our_decode(self, enc): def decodeit(value, enc): if hasattr(value,'file'): return value elif isinstance(value,list): return [v.decode(enc) for v in value] elif isinstance(value,dict): for k,v in value.items(): value[k] = decodeit(v,enc) else: return value.decode(enc) decodedParams = {} for key, value in cherrypy.request.params.items(): decodedParams[key] = decodeit(value,enc) cherrypy.request.params = decodedParams from cherrypy.filters.decodingfilter import DecodingFilter DecodingFilter.decode = our_decode #--------------8<-------------------------
(import this code at the beginning of the project to monkeypatch DecodingFilter?)
Cheers,
jhb (mail1 at baach dot de)
Change History
10/25/06 16:11:52: Modified by fumanchu
- owner changed from rdelon to fumanchu.
- status changed from new to assigned.
11/22/06 18:20:27: Modified by fumanchu
- status changed from assigned to closed.
- resolution set to invalid.
A dict cannot be passed in as a request parameter. There are ways to provide this on top of CherryPy, and that's enough.


I commented on your Trac ticket.