I created a custom url regular handler, which works in the app.route, but does not take effect in the api.route of the blueprint. The error message is: File "d:\Anaconda3\lib\site-packages\ Werkzeug\routing.py", line 696, in get_converter
Raise LookupError('the converter %r does not exist' % converter_name)
LookupError: the converter 'regex' does not exist
·
from werkzeug.routing import BaseConverter
class RegexConverter(BaseConverter):
def __init__(self, map, *args):
self.map = map
self.regex = args[0]
app.url_map.converters['regex'] = RegexConverter
manager = Manager(app)
# Printed here has regex
print('\n\n',app.url_map.converters,'<---------------->',manager.app.url_map.converters,'\n\n')
But I printed it in routing.Rule.get_converter but there is no regex in self.map.converters
The data for app.url_map.converters is not passed to the blueprint
Traceback (most recent call last):
File "devServer.py", line 5, in <module>
from manage import app
File "D:\py3\ytt\manage.py", line 30, in <module>
app = create_app('development')
File "D:\py3\ytt\app\__init__.py", line 62, in create_app
app.register_blueprint(api_bp)
File "d:\Anaconda3\lib\site-packages\flask\app.py", line 66, in wrapper_func
return f(self, *args, **kwargs)
File "d:\Anaconda3\lib\site-packages\flask\app.py", line 1115, in register_blueprint
blueprint.register(self, options, first_registration)
File "d:\Anaconda3\lib\site-packages\flask\blueprints.py", line 187, in register
deferred(state)
File "d:\Anaconda3\lib\site-packages\flask\blueprints.py", line 208, in <lambda>
s.add_url_rule(rule, endpoint, view_func, **options))
File "d:\Anaconda3\lib\site-packages\flask\blueprints.py", line 80, in add_url_rule
view_func, defaults=defaults, **options)
File "d:\Anaconda3\lib\site-packages\flask\app.py", line 66, in wrapper_func
return f(self, *args, **kwargs)
File "d:\Anaconda3\lib\site-packages\flask\app.py", line 1216, in add_url_rule
self.url_map.add(rule)
File "d:\Anaconda3\lib\site-packages\werkzeug\routing.py", line 1217, in add
rule.bind(self)
File "d:\Anaconda3\lib\site-packages\werkzeug\routing.py", line 687, in bind
self.compile()
File "d:\Anaconda3\lib\site-packages\werkzeug\routing.py", line 741, in compile
_build_regex(self.is_leaf and self.rule or self.rule.rstrip('/'))
File "d:\Anaconda3\lib\site-packages\werkzeug\routing.py", line 730, in _build_regex
variable, converter, c_args, c_kwargs)
File "d:\Anaconda3\lib\site-packages\werkzeug\routing.py", line 696, in get_converter
raise LookupError('the converter %r does not exist' % converter_name)
LookupError: the converter 'regex' does not exist
Expected Behavior
I created a custom url regular handler, which works in the app.route, but does not take effect in the api.route of the blueprint. The error message is: File "d:\Anaconda3\lib\site-packages\ Werkzeug\routing.py", line 696, in get_converter Raise LookupError('the converter %r does not exist' % converter_name) LookupError: the converter 'regex' does not exist ·
But I printed it in routing.Rule.get_converter but there is no regex in self.map.converters
{'default': <class 'werkzeug.routing.UnicodeConverter'>, 'string': <class 'werkzeug.routing.UnicodeConverter'>, 'any': <class 'werkzeug.routing.AnyConverter'>, 'path': <class 'werkzeug.routing.PathConverter'>, 'int': <class 'werkzeug.routing.IntegerConverter'>, 'float': <class 'werkzeug.routing.FloatConverter'>, 'uuid': <class 'werkzeug. routing.UUIDConverter'>}
Actual Behavior
The data for app.url_map.converters is not passed to the blueprint
Environment