List Info

Thread: Case-insensitive parameters




Case-insensitive parameters
user name
2006-04-03 00:55:29
Oh dear, i did say i hadn't tested it didn't I - it turns
out i hadn't
read it either ! Try this instead ...

def index(*args, **kwargs):
    kwargslowercase = {}
    for k,v in kwargs.iteritems():
        kwargslowercase[str(k).lower()] = v
    #Now use kwargslowercase as a dictionary
    #of HTTP parameters all of which are lowercase
    #- just demonstrate that
    for v in kwargslowercase.itervalues():
        print v


--~--~---------~--~----~------------~-------~--~----~
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 http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Case-insensitive parameters
user name
2006-04-03 06:55:00
northof40, ionel,

 Thanks for the input! I went with the **kwargs idea since,
well, it
was the first response I got and once I started travelling
down that
road, I couldn't turn back 

 I was able to get it working using the code suggested by
northof40 below.

 Thanks all for the quick response. I have to say that after
trying
out zope/plone, django and twisted, cherrypy seems like the
most solid
and intuitive way to launch web services. I'm very psyched
about the
potential.

Anyone else using cherrypy for web services other than html
servers?

matt

On 4/2/06, northof40 <shearichardgmail.com> wrote:
> Try this instead ...
>
> def index(*args, **kwargs):
>     kwargslowercase = {}
>     for k,v in kwargs.iteritems():
>         kwargslowercase[str(k).lower()] = v
>     #Now use kwargslowercase as a dictionary
>     #of HTTP parameters all of which are lowercase
>     #- just demonstrate that
>     for v in kwargslowercase.itervalues():
>         print v


On 4/2/06, Maries Ionel Cristian <ionel.mcgmail.com> wrote:
> actualy alters the params dict not the request line

> you got the idea... just have all parameters in
lowercase in the serving
> methods
>
>
> On 4/3/06, Maries Ionel Cristian <ionel.mcgmail.com> wrote:
> >
> > you could make a filter that alters the request
line.
> > for example:
> >
> > class LowerParams:
> >     def before_request_body(this):
> >         cherrypy.request.params = dict(
> >         [ (x[0].lower(),x[1]) for x in
cherrypy.request.params.items() ]
> >         )
> >
> > and have something like:
> >
> > class Root:
> >     _cp_filters = [ LowerParams(), ]
> >


--
Matt Perry
perrygeogmail.com
http://www.perrygeo.net

--~--~---------~--~----~------------~-------~--~----~
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 http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

[1-2]

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