Skip to content
Myr

Fix registering partials as view functions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ThiefMaster · committed by ThiefMaster · parent 8ceff65 · Browse files · 3 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+5 added−1 removed

  • tests:+3 added−0 removed
  • other:+2 added−1 removed

3 files+5 added−1 removed

modified:flask/blueprints.py+1 added-1 removed
199 unmodified lines
200 the :func:`url_for` function is prefixed with the name of the blueprint.201 """202 if endpoint:203 assert '.' not in endpoint, "Blueprint endpoints should not contain dots"204 if view_func:204 if view_func and hasattr(view_func, '__name__'):205 assert '.' not in view_func.__name__, "Blueprint view function name should not contain dots"206 self.record(lambda s:207 s.add_url_rule(rule, endpoint, view_func, **options))208
239 unmodified lines
modified:tests/test_blueprints.py+3 added
7 unmodified lines
8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10"""1112import functools13import pytest1415import flask16
365 unmodified lines
382 '/bar/123', view_func=foo_foo_foo383 )384 )385386 bp.add_url_rule('/bar/456', endpoint='foofoofoo', view_func=functools.partial(foo_foo_foo))387388 app.register_blueprint(bp, url_prefix='/py')389390 assert client.get('/py/foo').data == b'bp.foo'391 # The rule's didn't actually made it through
454 unmodified lines
modified:CHANGES.rst+1 added
7 unmodified lines
8-------------910unreleased1112- Fix registering partials (with no ``__name__``) as view functions1314Version 1.015-----------16
845 unmodified lines