forked from orbit-oss/flask
Fix registering partials as view functions
This commit is contained in:
parent
8ceff653c5
commit
6663bf1f7d
3 changed files with 5 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ Version 1.0.1
|
|||
|
||||
unreleased
|
||||
|
||||
- Fix registering partials (with no ``__name__``) as view functions
|
||||
|
||||
Version 1.0
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class Blueprint(_PackageBoundObject):
|
|||
"""
|
||||
if endpoint:
|
||||
assert '.' not in endpoint, "Blueprint endpoints should not contain dots"
|
||||
if view_func:
|
||||
if view_func and hasattr(view_func, '__name__'):
|
||||
assert '.' not in view_func.__name__, "Blueprint view function name should not contain dots"
|
||||
self.record(lambda s:
|
||||
s.add_url_rule(rule, endpoint, view_func, **options))
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
import functools
|
||||
import pytest
|
||||
|
||||
import flask
|
||||
|
|
@ -382,6 +383,8 @@ def test_route_decorator_custom_endpoint_with_dots(app, client):
|
|||
)
|
||||
)
|
||||
|
||||
bp.add_url_rule('/bar/456', endpoint='foofoofoo', view_func=functools.partial(foo_foo_foo))
|
||||
|
||||
app.register_blueprint(bp, url_prefix='/py')
|
||||
|
||||
assert client.get('/py/foo').data == b'bp.foo'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue