If both _anchor and _query are specified, the anchor element will always follow the query element, e.g. http://example.com?foo=1#bar.
If any of the keyword arguments _scheme, _host, or _port is passed and is non-None, the provided value will replace the named portion in the generated URL. For example, if you pass _host=’foo.com’, and the URL that would have been generated without the host replacement is http://example.com/a, the result will be https://foo.com/a.
Note that if _scheme is passed as https, and _port is not passed, the _port value is assumed to have been passed as 443. Likewise, if _scheme is passed as http and _port is not passed, the _port value is assumed to have been passed as 80. To avoid this behavior, always explicitly pass _port whenever you pass _scheme.
If a keyword _app_url is present, it will be used as the protocol/hostname/port/leading path prefix of the generated URL. For example, using an _app_url of http://example.com:8080/foo would cause the URL http://example.com:8080/foo/fleeb/flub to be returned from this function if the expansion of the route pattern associated with the route_name expanded to /fleeb/flub. If _app_url is not specified, the result of request.application_url will be used as the prefix (the default).
If both _app_url and any of _scheme, _host, or _port are passed, _app_url takes precedence and any values passed for _scheme, _host, and _port will be ignored.
This function raises a KeyError if the URL cannot be generated due to missing replacement names. Extra replacement names are ignored.
If the route object which matches the route_name argument has a pregenerator, the *elements and **kw arguments arguments passed to this function might be augmented or changed.
route_path(route_name, *elements, **kw)
Generates a path (aka a ‘relative URL’, a URL minus the host, scheme, and port) for a named Pyramid route configuration.
This function accepts the same argument as pyramid.request.Request.route_url() and performs the same duty. It just omits the host, port, and scheme information in the return value; only the script_name, path, query parameters, and anchor data are present in the returned string.
For example, if you’ve defined a route named ‘foobar’ with the path /{foo}/{bar}, this call to route_path: