comparison src/server/pages.py @ 1110:045e8bdaed4f

pages: ignore args if they are None in getSubPageURL
author Goffi <goffi@goffi.org>
date Thu, 21 Jun 2018 01:19:47 +0200
parents 3a7b2b239d3e
children cdd389ef97bc
comparison
equal deleted inserted replaced
1109:3a7b2b239d3e 1110:045e8bdaed4f
489 and potential redirections. 489 and potential redirections.
490 @param request(server.Request): current HTTP request 490 @param request(server.Request): current HTTP request
491 @param page_name(unicode): name of the page to retrieve 491 @param page_name(unicode): name of the page to retrieve
492 it must be a direct children of current page 492 it must be a direct children of current page
493 @param *args(list[unicode]): arguments to add as path elements 493 @param *args(list[unicode]): arguments to add as path elements
494 if an arg is None, it will be ignored
494 @return (unicode): absolute URL to the sub page 495 @return (unicode): absolute URL to the sub page
495 """ 496 """
496 current_url = self.getCurrentURL(request) 497 current_url = self.getCurrentURL(request)
497 path, child = self.getSubPageByName(page_name) 498 path, child = self.getSubPageByName(page_name)
498 return os.path.join(u'/', current_url, path, *[quote(a) for a in args]) 499 return os.path.join(u'/', current_url, path, *[quote(a) for a in args if a is not None])
499 500
500 def getURLByNames(self, named_path): 501 def getURLByNames(self, named_path):
501 """retrieve URL from pages names and arguments 502 """retrieve URL from pages names and arguments
502 503
503 @param named_path(list[tuple[unicode, list[unicode]]]): path to the page as a list 504 @param named_path(list[tuple[unicode, list[unicode]]]): path to the page as a list