Add support for name parameter to route decorators

If a url_path with parameters is specified in a route decorator, the
view name includes the parameters. Using the name parameter, the view
name can be overridden.
This commit is contained in:
Michel Wilson 2015-03-04 22:13:18 +01:00
parent f7917928c0
commit b067aea79f

View File

@ -172,10 +172,11 @@ class SimpleRouter(BaseRouter):
initkwargs = route.initkwargs.copy()
initkwargs.update(method_kwargs)
url_path = initkwargs.pop("url_path", None) or methodname
name = replace_methodname(route.name, initkwargs.pop("name", url_path))
ret.append(Route(
url=replace_methodname(route.url, url_path),
mapping=dict((httpmethod, methodname) for httpmethod in httpmethods),
name=replace_methodname(route.name, url_path),
name=name,
initkwargs=initkwargs,
))