Reputation: 9091
I use URL Dispatch in Pyramid framework. As far as I can see, there is a requirement that each route has a unique name. Is there a way to associate multiple paths with a single route? In particular, I would like to have two different addresses display the same content. Note: I don't want to perform redirection.
Upvotes: 2
Views: 825
Reputation: 15690
do you mean something like this...
in your config:
config.add_route('path::a', 'path/a')
config.add_route('path::b', 'path/b')
in your views:
class ViewClass(handlerClass):
@view_config(renderer="/path.mako",route_name="path::a")
@view_config(renderer="/path.mako",route_name="path::b")
def path(self):
return {'project':'MyApp'}
Upvotes: 3
Reputation: 56951
You mean, two different paths to be handled by a single controller / view? Is something like this you are looking for?
config.add_route('idea', 'path/{id}')
config.add_route('newidea', 'newpath/{id}')
config.add_view('mypackage.views.site_view', route_name='idea')
config.add_view('mypackage.views.site_view', route_name='newidea')
Upvotes: 3