Search code examples
pythonroutespylons

Pylons Routes url_for for a map.resource


How do I get the get, post, put and delete URLs for a restful routes resource using url_for?

For example, how do I get the PUT URL for a resource with id=1, and routes defined in routing.py like so:

map.resource('user', 'users', controller='user')

I know the correct URL is /users/1, but I don't want to hard code it.


Solution

  • Check out: http://routes.groovie.org/restful.html

    url('user', id=1)
    

    should give you '/users/1'