Search code examples
pythonpython-2.7http-redirectweb2pyweb2py-modules

Redirect URL with parameters in web2py controller


I am trying to redirect to a URL('form','results') from forminput.html with parameters (in my case, it's a huge dictionary i.e. output). But when the web page is redirected to results.html, all the parameters are also included in the web Url itself, which what we don't want for two reasons, security and lenthy type of urls.
Can you help me in this scenario ?
Thanks in advance

Here is the sample of URL.
http://127.0.0.1:8000/AWS/form/results?csp=&ibx=&metro=&o=%7B%22se1.sv1%22%3A+%7B%22xe-0%2F2%2F1%22%3A+%7B%22Util%22%3A+66%2C%22c_name%22%3A+%22dxcon-fh26tz6s%22%2C%22c_serial%22%3A+%2215563580-A%22%7D%2C%22xe-2%2F1%2F3%22%3A+%7B%22Util%22%3A+31%2C%22c_name%22%3A+%22dxcon-fgptdigg%22%2C%22c_serial%22%3A+%2220130277-A%22%7D%2C%22xe-3%2F0%2F3%22%3A+%7B%22Util%22%3A+0%2C%22c_name%22%3A+%22SFDC-SV3-CX-SEC-01%22%2C%22c_serial%22%3A+%2220375541-A%22%7D%2C%22xe-3%2F1%2F2%22%3A+%7B%22Util%22%3A+0%2C%22c_name%22%3A+%22dxcon-ffj66n3f%22%2C%22c_serial%22%3A+%2220347645-A%22%7D%2C%22xe-3%2F2%2F3%22%3A+%7B%22Util%22%3A+0%2C%22c_name%22%3A+%22dxcon-fgsmxuat%22%2C%22c_serial%22%3A+%2220366330-A%22%7D%7D%7D#

/*this my controller, form.py*/

my_funct():
    out_dict=dict()  // out_dict is a huge dictionary with 100 of keys and values  
    return out_dict

define forminput():  
    outout=my_funct()  
    redirect(URL('form','results', vars= dict(out=output)))  

define results():  
    data=request.vars['out']  

Solution

  • You can instead store the data in the session (which remains on the server):

    define forminput():  
        session.data = my_funct()  
        redirect(URL('form', 'results'))  
    
    define results():  
        data = session.data