I have a Pyramid application that adds routes using:
config.add_route("home", "/")
config.add_view(
homeView,
route_name="home",
"home.jinja2",
)
After the main app and the plugins add the routes I would like to get the URL of a route for example "home". In views I use "request.route_url()" but I need to get the same during the initialization of the App, meaning just after
config.make_wsgi_app()
I tried to use the registry introspection:
config.add_route("home", "/")
config.add_view(
homeView,
route_name="home",
"home.jinja2",
)
config.make_wsgi_app()
introspector = config.registry.introspector
route_intr = introspector.get('routes', "home")
print(route_intr)
But I get a route object with path and name but not with host, port, etc. I also tried:
from pyramid.interfaces import IRoutesMapper
mapper = config.registry.getUtility(IRoutesMapper)
route = mapper.get_route("home")
I saw some code in Flask one can do something like this:
from flask.helpers import url_for
app.register_blueprint(views)
url = url_for("home")
Is there something like that for Pyramid? Basically, I need to get for the route "home" the same result as if I would do request.route_url("home") which is "
http://localhost:5900/"