I'm trying to create a website with optional url sub-paths:
- /user - Returns general information on users
- /user/edit - Edits the user
I've tried setting:
config.add_route('user', '/user/{action}')
@view_defaults(route_name="user")
class UserViews():
# not sure what (if anything) to put in @view_config here...
def user_general(self):
return Response("General User Info"
@view_config(match_param="action=edit")
def edit(self):
return Response("Editing user")
However while this works for /user/edit, it returns a 404 for /user
It also fails in the same way if I set 2 explicit routes with a shared path - e.g.:
config.add_route('login', '/user')
config.add_route('edit_user', '/user/edit')
I've tried things like setting match_params="action=" but can't get it to work.
Any ideas on how this can be achieved?