INNER CODE UNIT · Python
urls_for_component_page
rio-labs/rio · rio/app.py:620
def urls_for_component_page(page: rio.ComponentPage) -> t.Iterator[str]:
# A page can have multiple URLs if it has path parameters. Start by
# creating a list of URLs that are valid for this page.
if page._url_pattern.path_parameter_names:
# If this page has path parameters, we don't know what it
# considers a valid URL. One exception are Literals - we simply
# insert every allowed value into the URL.
options = dict[str, t.Sequence[str]]()
for parameter in page._url_pattern.path_parameter_names:
parser = page._url_parameter_parsers[parameter]
try:
options[parameter] = parser.list_valid_values()
except ValueError:
# If a parser can't reasonably list all of its valid
# values, then we simply won't generate any URLs for
# this page at all.