allow customizing url map class

This commit is contained in:
shidenggui 2019-01-08 15:56:55 +08:00 committed by David Lord
parent b0185a6205
commit 2a2a11b063
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
2 changed files with 9 additions and 1 deletions

View file

@ -40,6 +40,8 @@ Unreleased
:issue:`3134`
- :meth:`jsonify` supports :class:`dataclasses.dataclass` objects.
:pr:`3195`
- Allow customizing the :attr:`Flask.url_map_class` used for routing.
:pr:`3069`
.. _#2935: https://github.com/pallets/flask/issues/2935
.. _#2957: https://github.com/pallets/flask/issues/2957

View file

@ -350,6 +350,12 @@ class Flask(_PackageBoundObject):
#: .. versionadded:: 0.7
url_rule_class = Rule
#: The map object to use for storing the URL rules and routing
#: configuration parameters. Defaults to :class:`werkzeug.routing.Map`.
#:
#: .. versionadded:: 1.1.0
url_map_class = Map
#: the test client that is used with when `test_client` is used.
#:
#: .. versionadded:: 0.7
@ -567,7 +573,7 @@ class Flask(_PackageBoundObject):
#:
#: app = Flask(__name__)
#: app.url_map.converters['list'] = ListConverter
self.url_map = Map()
self.url_map = self.url_map_class()
self.url_map.host_matching = host_matching
self.subdomain_matching = subdomain_matching