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():

I also need to get the 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?

Repoze-dev mailing list

Reply via email to