Allow passing the endpoint to the route decorators on Flask's application and blueprints.

This commit is contained in:
Pedro Algarvio 2011-08-25 11:46:05 +01:00
parent 1bca65d72e
commit 68ec5a3068
3 changed files with 64 additions and 2 deletions

View file

@ -942,7 +942,8 @@ class Flask(_PackageBoundObject):
:class:`~werkzeug.routing.Rule` object.
"""
def decorator(f):
self.add_url_rule(rule, None, f, **options)
endpoint = options.pop("endpoint", None)
self.add_url_rule(rule, endpoint, f, **options)
return f
return decorator

View file

@ -157,7 +157,8 @@ class Blueprint(_PackageBoundObject):
:func:`url_for` function is prefixed with the name of the blueprint.
"""
def decorator(f):
self.add_url_rule(rule, f.__name__, f, **options)
endpoint = options.pop("endpoint", f.__name__)
self.add_url_rule(rule, endpoint, f, **options)
return f
return decorator