Can I pass dictionary in HttpRedirection or HttpFound in webob in python?

421 Views Asked by At

I am trying to pass a dictionary to HttpRedirect or HttpFound method so that I can use this dictionary at the redirected url.

I am using route module for url connect and using cherrypy and webob for Https.

I want to do like this return HttpRedirect(location=location, mydict)

where HttpRedirect extends HttpFound of webob

1

There are 1 best solutions below

2
Francesco Montesano On

you have (at least) two ways

  1. HttpRedirect(mydict, location=location) or HttpRedirect(httpdict=mydict, location=location): explicitly pass the dictionary as positional argument or keyword argument and then access the dictionary
  2. use a more abstract and flexible approach implementing something like this HttpRedirect(location=location, **kargs) and then passing mydict doing HttpRedirect(location=location, **mydic).

for a short tutorial on positional and keyword arguments read here