List Info

Thread: tools.decode + routesdispatcher




tools.decode + routesdispatcher
country flaguser name
United States
2007-09-20 04:38:45
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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: tools.decode + routesdispatcher
country flaguser name
United States
2007-09-20 09:59:44
http://www.cherryp
y.org/ticket/730

well, it have been fixed :p


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: tools.decode + routesdispatcher
country flaguser name
United States
2007-09-20 10:34:55
d.rothe wrote:
> 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.

Could you open a ticket for this, please? I have a fix
ready
to go but it would be good to have one place to collect the
discussion.


Robert Brewer
fumanchuaminus.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


  
Re: tools.decode + routesdispatcher
country flaguser name
United States
2007-09-20 12:04:29
done.

http://www.cherryp
y.org/ticket/732


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )