On Fri, Mar 5, 2010 at 10:32 AM, georgehu geo...@gmail.com wrote:
I'm writing a helper function for paginating the data, the function needs
to append a query string to the url to compose a new url with page number,
and I decide to use the request object to get the url and then change it.
The function I use to construct the url is route_url, I got an issue of
using matchdict in the route_url, in the following syntax:
route_url(route_name, self.request, **self.request.matchdict)
It said Keyword must be string, So I have to add the following codes to
change the keyword to string:
for k,v in self.request.matchdict.items():
link_params[str(k)]=v
I also need to get the route name:
route_name=self.reqeust.environ['bfg.routes.route'].name,
Am I making simple things complicated? Well, my target is to generate a url
from /a to /a?page=1, why should I go through the process of breaking
down then composing again? I finally found the request.url is a more
straightforward way. My question is, which way should I choose? Is there a
best practice guide to manipulating the url?
Hi George,
Are you aware of the '_query' parameter to route_url?
q = dict(page=1)
url =route_url(route_name, request, _query=q)
It doesn't answer all your question but may help.
Best,
Darryl
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev