Displaying request.vars

47 views
Skip to first unread message

Gael Princivalle

unread,
Mar 5, 2015, 5:41:09 AM3/5/15
to web...@googlegroups.com
Hello.

I would like to build an URL using request.args.

Something like that:


But the result is:

<a href="http://www.mydomain.com/index?&lt;Storage {'product_id': '8'}">
    Go
</a>

And it should be:

Someone have a solution?

Thanks, regards.

Leonel Câmara

unread,
Mar 5, 2015, 6:20:25 AM3/5/15
to web...@googlegroups.com

Anthony

unread,
Mar 5, 2015, 6:36:35 AM3/5/15
to web...@googlegroups.com
Is it a web2py URL? If so, you can do URL(..., vars=request.vars).

Antony

黄祥

unread,
Mar 5, 2015, 6:53:47 AM3/5/15
to web...@googlegroups.com
index.html
{{=A(_href = URL(vars = dict(product_id = request.vars) ) ) }}

best regards,
stifan

Anthony

unread,
Mar 5, 2015, 8:30:06 AM3/5/15
to web...@googlegroups.com


On Thursday, March 5, 2015 at 6:53:47 AM UTC-5, 黄祥 wrote:
index.html
{{=A(_href = URL(vars = dict(product_id = request.vars) ) ) }}


"product_id" is already in request.vars (which acts like a dict), so no need to create a new dict with a "product_id" key.

Anthony

Gael Princivalle

unread,
Mar 5, 2015, 11:15:27 AM3/5/15
to web...@googlegroups.com
Thanks a lot Leonel, it's exactly what I was searching for.
@Antony thanks but in this case it was not the current web2py url (a .load file), but another that calla the .load file.

Anthony

unread,
Mar 5, 2015, 1:03:30 PM3/5/15
to web...@googlegroups.com
On Thursday, March 5, 2015 at 11:15:27 AM UTC-5, Gael Princivalle wrote:
Thanks a lot Leonel, it's exactly what I was searching for.
@Antony thanks but in this case it was not the current web2py url (a .load file), but another that calla the .load file.

As long as it is a web2py URL, you can and should use the URL function -- just specify the controller and function (and app if it's a different app):

URL('default', 'index', vars=request.get_vars, extension=False)

The extension=False argument will suppress the extension, so it won't propogate the .load extension.

Anthony
Reply all
Reply to author
Forward
0 new messages