How to generate an URL with Pyramid and Akhet?

975 views Asked by At

I'm creating an Akhet (Pyramid) web application. How can one generate in a mako template the URL for a given Handler/view ?

I'm looking for the equivalent of Pylons' ${url(controller="users", view="list")

2

There are 2 answers

1
Michael Merickel On BEST ANSWER

Akhet exposes the URLGenerator object as a renderer global, so you can just use url('users', action='list'), assuming config.add_handler('users', '/users/{action}', ...) in your setup.

http://docs.pylonsproject.org/projects/akhet/dev/api.html#module-akhet.urlgenerator

1
Rick On

You need to use route_url. It's available in the templates in request.route_url.

<a href="${request.route_url('import')}">Import</a>

for example