While experimenting with ajax routes, I discovered that the ajax route match only works for the first forward slash '/'. Anything after the initial forward slash is disregarded.
For instance,
View.py
@view_config(name="a", renderer="json")
def server_viewtest_a(request):
return {}
@view_config(name="a/b", renderer="json")
def server_viewtest_ab(request):
return {}
test.js
$.get('a/b', function (result) {
});
In the above ajax call to route 'a/b', it mistakenly matches with 'server_viewtest_a' instead of 'server_view_ab'. Subsequent forward slashes are not considered at all.
Is there a way to include forward slashes in ajax call routes? If so, how can this be achieved?
Edit
To clarify, I managed to make it work by using the following code. However, my intention was to utilize 'name' instead of 'route_name' in my @view_config so that I wouldn't need to define each route with "config.add_route()" in my __init__.py file. Is there a method to accomplish this solely using "name"?
__init__.py
config.add_route('a', 'a')
config.add_route('a/b', 'a/b')
View.py
@view_config(route_name="a", renderer="json")
def server_viewtest_a(request):
return {}
@view_config(route_name="a/b", renderer="json")
def server_viewtest_ab(request):
return {}