I have a Pyramid application that adds routes using:

    config.add_route("home", "/")
            config.add_view(
                homeView,
                route_name="home",
                "home.jinja2",
            )

The application uses PCA https://github.com/PyUtilib/pyutilib therefore 
plug-ins can add routes to the main application.

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/";

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/40b8550f-f57a-4152-a744-0bb4304251een%40googlegroups.com.

Reply via email to