request.route_url() has a _query argument that is documented.

request.route_url('countries_list', _query={'sort': 'foo', 'dir': 'asc'})
# -> http://127.0.0.1:6543/countries/list?sort=foo&dir=asc

http://docs.pylonsproject.org/projects/pyramid/en/1.2-branch/api/request.html#pyramid.request.Request.route_url

On Thu, Dec 8, 2011 at 12:33 PM, Cem Ikta <[email protected]> wrote:

> Hi,
>
> How can I add query parameters to the current url in my view code?
>
> I would like to add new parameters to current url if there are no
> parameters
>
> for example: 
> http://127.0.0.1:6543/**countries/list?sort=code<http://127.0.0.1:6543/countries/list?sort=code>
>
> I am using mako + url dispatch.
>
> @view_config(route_name="
> **countries_list", renderer="countries/list.html"**)
> def list(request):
>     """countries list """
>     if request.GET.get("sort"):
>        sort = request.GET.get("sort")
>      else:
>        # TODO: add new sort parameter in current url ?
>
>     dbsession = DBSession()
>     countries = dbsession.query(Country).**order_by(sort)
>
>      #TODO:how to return current url with new sort parameter ?
>
>     return {"countries": countries}
>
>
> Thanks.
> Cem
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/ByF2QQn1D30J.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to