python - CherryPy: What would the html command line syntax be if you wanted to pass a dictionary as an argument? -
so built simple cherrypy function called 'echo' seek , figure out cherrypy sends python function. example:
http://djotjog.com/cp/echo/692-gg_org_id-2013-02-05.json/ returns: {'kw': {}, 'args': (), 'param_1': '692-gg_org_id-2013-02-05.json', 'param_2': none}
now, may seem weird, pass dictionary. html nightmare do? example:
this function needs 2 arguments. params optional:
def some_function(filename, params = {'db':'bh-localhost','h':'sparse','branching':7})
sending through cherrypy...
http://djotjog.com/cp/echo/692-gg_org_id-2013-02-05.json/{h:'branchy','branching':7,'db':'bh-localhost'} returns {'kw': {}, 'args': (), 'param_1': '692-gg_org_id-2013-02-05.json', 'param_2': "{h:'branchy','branching':7,'db':'bh-localhost'}"}
but when pass through through actual function , not echo, tells me:
404 not found. nil matches given uri.
is because dictionary string , not dict now? trick can pass dictionary? or maintain individual arguments?
try setting echo receive variable number of parameters...
@cherrypy.expose def echo(self, *args, **kwargs): homecoming kwargs['param_1']
hope helps.
andrew
python cherrypy
No comments:
Post a Comment