From 2a2a11b0634df4932eb0b4113009759ce4d1754a Mon Sep 17 00:00:00 2001 From: shidenggui Date: Tue, 8 Jan 2019 15:56:55 +0800 Subject: [PATCH] allow customizing url map class --- CHANGES.rst | 2 ++ flask/app.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a1150437..45fe3651 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 diff --git a/flask/app.py b/flask/app.py index 8424ce98..acbc00e7 100644 --- a/flask/app.py +++ b/flask/app.py @@ -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