remove deprecated Request.module
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent d63c2bc · Browse files · 3 files·+19 added−49 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+19 added−49 removed
- tests:+0 added−13 removed
- other:+19 added−36 removed
Provenance
- Commit
723e665- Tree
57a910b- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
d63c2bc
3 files changed+19 added−49 removed
modified:flask/helpers.py+19 added-19 removed
266 unmodified lines267 :param _method: if provided this explicitly specifies an HTTP method.268 """269 appctx = _app_ctx_stack.top270 reqctx = _request_ctx_stack.top271+272 if appctx is None:272- raise RuntimeError('Attempted to generate a URL without the '273- 'application context being pushed. This has to be '274- 'executed when application context is available.')273+ raise RuntimeError(274+ 'Attempted to generate a URL without the application context being'275+ ' pushed. This has to be executed when application context is'276+ ' available.'277+ )278 279 # If request specific information is available we have some extra280 # features that support "relative" URLs.281 if reqctx is not None:282 url_adapter = reqctx.url_adapter283 blueprint_name = request.blueprint281- if not reqctx.request._is_old_module:282- if endpoint[:1] == '.':283- if blueprint_name is not None:284- endpoint = blueprint_name + endpoint285- else:286- endpoint = endpoint[1:]287- else:288- # TODO: get rid of this deprecated functionality in 1.0289- if '.' not in endpoint:290- if blueprint_name is not None:291- endpoint = blueprint_name + '.' + endpoint292- elif endpoint.startswith('.'):284+285+ if endpoint[:1] == '.':286+ if blueprint_name is not None:287+ endpoint = blueprint_name + endpoint288+ else:289 endpoint = endpoint[1:]290+291 external = values.pop('_external', False)292 293 # Otherwise go with the url adapter from the appctx and make294 # the URLs external by default.295 else:296 url_adapter = appctx.url_adapter297+298 if url_adapter is None:301- raise RuntimeError('Application was not able to create a URL '302- 'adapter for request independent URL generation. '303- 'You might be able to fix this by setting '304- 'the SERVER_NAME config variable.')299+ raise RuntimeError(300+ 'Application was not able to create a URL adapter for request'301+ ' independent URL generation. You might be able to fix this by'302+ ' setting the SERVER_NAME config variable.'303+ )304+305 external = values.pop('_external', True)306 307 anchor = values.pop('_anchor', None)308 method = values.pop('_method', None)711 unmodified linesmodified:flask/wrappers.py-17 removed
139 unmodified lines140 #: usually a :exc:`~werkzeug.exceptions.NotFound` exception or141 #: something similar.142 routing_exception = None143 144- # Switched by the request context until 1.0 to opt in deprecated145- # module functionality.146- _is_old_module = False147-144 @property145 def max_content_length(self):146 """Read-only view of the ``MAX_CONTENT_LENGTH`` config key."""147 if current_app:9 unmodified lines157 if self.url_rule is not None:158 return self.url_rule.endpoint159 160 @property165- def module(self):166- """The name of the current module if the request was dispatched167- to an actual module. This is deprecated functionality, use blueprints168- instead.169- """170- from warnings import warn171- warn(DeprecationWarning('modules were deprecated in favor of '172- 'blueprints. Use request.blueprint '173- 'instead.'), stacklevel=2)174- if self._is_old_module:175- return self.blueprint176-177- @property161 def blueprint(self):162 """The name of the current blueprint"""163 if self.url_rule and '.' in self.url_rule.endpoint:164 return self.url_rule.endpoint.rsplit('.', 1)[0]34 unmodified linesmodified:tests/test_deprecations.py-13 removed
7 unmodified lines8 :copyright: (c) 2015 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10 """11 12-import pytest13-12 import flask13 14 15 class TestRequestDeprecation(object):7 unmodified lines23 return 'OK'24 25 client.post('/', data='{"spam": 42}', content_type='application/json')26 recwarn.pop(DeprecationWarning)29-30- def test_request_module(self, recwarn, app, client):31- """Request.module is deprecated"""32-33- @app.route('/')34- def index():35- assert flask.request.module is None36- return 'OK'37-38- client.get('/')39- recwarn.pop(DeprecationWarning)