Commit Graph

57 Commits

Author SHA1 Message Date
David Lord 4995a775df
fix subdomain_matching=False behavior 2024-11-12 08:58:08 -08:00
David Lord 54ff9b2972
use ruff linter and formatter 2023-11-09 10:27:01 -08:00
Evgeny Mozhaev b8b410014d
require a non-empty name for blueprints 2023-03-11 08:26:36 -08:00
David Lord 6650764e97
remove previously deprecated code 2023-02-23 08:35:16 -08:00
pgjones cabda59353 Ensure that blueprint subdomains suffix-chain
This ensures that a child's subdomain prefixs any parent subdomain
such that the full domain is child.parent.domain.tld and onwards with
further nesting. This makes the most sense to users and mimics how
url_prefixes work (although subdomains suffix).
2023-01-04 18:06:04 +00:00
Josh Michael Karamuth d7b6c1f670 Fix subdomain inheritance for nested blueprints.
Fixes #4834
2023-01-04 16:19:52 +00:00
David Lord 96c97dec09
deprecate before_first_request 2022-06-06 10:04:05 -07:00
David Lord 48f2afbf90
same blueprint cannot be registered with same name 2021-11-12 09:52:16 -08:00
Matthias Paulsen 166a2a6207
Fix callback order for nested blueprints
Handlers registered via url_value_preprocessor, before_request,
context_processor, and url_defaults are called in downward order: First
on the app and last on the current blueprint.

Handlers registered via after_request and teardown_request are called
in upward order: First on the current blueprint and last on the app.
2021-10-03 20:27:24 -07:00
pgjones a44c722860 Fix registering a blueprint twice with differing names
Previously the blueprint recorded aspects (before request, after
request etc) would only be added to the app if it was the first
registration of the blueprint instance. However only the record-once
aspects (app-before requests, app-after request) should be added once
on registration of the instance, whereas everything else should be
added on every unique name registration. This ensures that these
trigger under the new name as well as the old.
2021-06-14 17:18:47 +00:00
pgjones 3257b7574e Fix blueprint renaming
This ensures that if a blueprint is renamed at the time of
registration that name is used when constructing endpoints, as
expected.
2021-05-21 15:04:30 +01:00
pgjones 714b0a467a Fix blueprint self registration
By raising a ValueError if attempted. I don't see a use case that
makes this worth supporting.
2021-05-21 15:04:30 +01:00
David Lord 9409be6e34 warn when registering same blueprint with same name 2021-05-21 15:04:30 +01:00
pgjones c2920e2bd9 Bugfix allow blueprints to be registered with a different name
This allows the same blueprint to be registered multiple times at the
same level, but with differing url_prefixes and names.
2021-05-21 15:04:18 +01:00
pgjones 99afbb277d Fix blueprint nested url_prefix
This ensures that the url_prefix is correctly applied, no matter if
set during the registration override or when constructing the
blueprint.
2021-05-21 15:04:18 +01:00
pgjones 6fbdeb80c7 Fix nested blueprint url_prefix
This fixes the case where the blueprint is registered with a
url_prefix but any child blueprints have no prefixes.
2021-05-17 15:47:25 +01:00
Grey Li e93704fbfd
fix url_prefix argument when nesting blueprints 2021-05-13 15:02:13 -07:00
David Lord 7c5261407d
blueprint name may not contain a dot 2021-05-13 14:31:50 -07:00
pgjones f92e820b4b
Nested blueprints
This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.
2021-04-14 09:25:42 -07:00
David Lord dc11cdb4a4
move send_file and send_from_directory to Werkzeug
The implementations were moved to Werkzeug, Flask's functions become
wrappers around Werkzeug to pass some Flask-specific values.

cache_timeout is renamed to max_age. SEND_FILE_MAX_AGE_DEFAULT,
app.send_file_max_age_default, and app.get_send_file_max_age defaults
to None. This tells the browser to use conditional requests rather than
a 12 hour cache.

attachment_filename is renamed to download_name, and is always sent if
a name is known.

Deprecate helpers.safe_join in favor of werkzeug.utils.safe_join.

Removed most of the send_file tests, they're tested in Werkzeug.

In the file upload example, renamed the uploaded_file view to
download_file to avoid a common source of confusion.
2020-11-05 09:27:52 -08:00
David Lord f2f027d1fb
remove unused module docstrings 2020-04-04 12:28:08 -07:00
David Lord 2ae740dd49
f-strings everywhere 2020-04-04 12:10:00 -07:00
David Lord 524fd0bc8c
apply pyupgrade 2020-04-04 12:10:00 -07:00
David Lord 662c245795
remove _compat module 2020-04-04 12:10:00 -07:00
David Lord 1351d0a565
Merge branch '1.0.x' 2019-06-23 16:57:52 -07:00
David Lord e666f7a69c
standardize license and copyright 2019-06-22 13:09:09 -07:00
David Lord 43483683b2
apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
Jon S. Stumpf b46f5942a5
address flake8 issues 2019-06-01 06:31:35 -07:00
David Baumgold 025589ee76 Reformat with black
https://github.com/python/black
2019-05-06 16:28:58 -04:00
David Lord b21b4d1608
add more merge cases 2018-05-01 13:29:48 -07:00
Hsiaoming Yang f7a3bdc6db
Fix blueprint route for "" 2018-05-01 14:35:55 +09:00
David Lord 4d0cdf95e6
merge slashes between blueprint prefix and rule 2018-04-27 12:40:06 -07:00
ThiefMaster 6663bf1f7d Fix registering partials as view functions 2018-04-27 13:44:07 +02:00
David Lord 401423df06
only strip one slash when registering blueprint
add test and changelog
2018-02-23 15:47:06 -08:00
David Lord 310fbfcf64
revert copyright year to project start
add copyright header to files
2018-02-08 12:43:30 -08:00
Caratpine 2f57a0b917
Blueprint view function name should not contain dots 2017-10-09 08:12:34 -07:00
Christian Stade-Schuldt 4ec1fbc9f5 More DRYing up the test suite (#2325) 2017-05-24 17:27:36 -07:00
David Lord 849fc4b90c Merge pull request #2323 from dawran6/test-fixture
Cleanup test_blueprint.py to use test fixtures
2017-05-23 17:14:57 -07:00
Randy Liou c03a82713a Cleanup test_blueprint.py to use test fixtures
Modify several tests to use the app and client test fixtures.
2017-05-23 16:42:14 -07:00
Randy Liou 3fce4898f8 Add test for Blueprint app-wide url processing
The test add coverage for methods: Blueprint.app_url_defaults, and
Blueprint.app_url_preprocessing. This PR increases the coverage of
blueprint module by 2%.
2017-05-23 16:26:53 -07:00
Christian Stade-Schuldt 5b0b9717da DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to conftest.py

* use fixtures in test_appctx.py

* use fixtures in test_blueprints.py

* use fixtures in test_depreciations.py

* use fixtures in test_regressions.py

* use fixtures in test_reqctx.py

* use fixtures in test_templating.py

* use fixtures in test_user_error_handler.py

* use fixtures in test_views.py

* use fixtures in test_basics.py

* use fixtures in test_helpers.py

* use fixtures in test_testing.py

* update conftest.py

* make docstrings  PEP-257 compliant

* cleanup

* switch dictonary format

* use pytest parameterization for test_json_as_unicode
2017-05-23 15:18:39 -07:00
Randy Liou d8d712a0de Add coverage for Blueprint teardown request method
Test the following methods in the Blueprint object: teardown_request,
and teardown_app_request.
This PR increases the coverage of blueprint module by 3%.
2017-05-22 16:58:04 -07:00
Randy Liou a690ae27a3 Add coverage for Blueprint request process methods
Add test to cover following methodss to the Blueprint object:
before_request, after_request, before_app_request,
before_app_first_request, after_app_request.
This PR increases the coverage of flask.blueprints by 6%.
2017-05-22 16:58:04 -07:00
Randy Liou 7ce01ab9b4 Add coverage for Blueprint.add_app_template_global
This tests the Blueprint.add_app_template_global mothod, which internally
calls the Blueprint.app_template_global method. The methods are used to
registering a function to the jinja template environment.
This PR increases the test coverage for module flask.blueprint by 4%.
2017-05-22 14:33:58 -07:00
David Lord e706b5e544 Merge pull request #2298 from dawran6/test-bp-context
Add coverage for Blueprints.(app_)context_processor
2017-05-22 14:01:59 -07:00
Randy Liou 136dbf7de0 Add coverage for Blueprints.(app_)context_processor
Test both context_processor and app_context_processor functions.
Two context parameters are added into the context: one added to
the blueprint locally; another added to the app globally. The test
asserts the behaviors in both blueprint scope and the app scope.
The coverage for flask.blueprints is increased by 3%.
2017-05-22 13:09:22 -07:00
Randy Liou 9fddecd4d9 Add coverage for Blueprint.app_errorhandler
This test case registers an application-wise error handler from
a Blueprint. Verifies the error handler by aborting the flask app
from the application itself as well as from another registered
Blueprint.
2017-05-22 12:00:04 -07:00
Randy Liou 954b7ef7bb Enhance code coverage for Blueprint.endpoint
Add basic test for the endpoint decorator for the Blueprint object.
2016-06-03 16:02:45 -07:00
Reuven 4dc2ef19ea Use pytest.raises() instead of try/catch with asser 0
This is somehow more readable, and enable using the features of pytest's ExeptionInfo (such as errisinstance).
2016-03-04 13:30:40 +02:00
Parkayun 33534bb4a9 Happy New Year 2015 2015-01-02 11:35:00 +09:00