Skip to content
Myr

Merge pull request #2394 from davidism/remove-deprecated

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Remove deprecated code

authored by David Lord · committed by GitHub · parents c5d3f80, 89c8724 · Browse files · 6 files+61 added−96 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+61 added−96 removed

  • tests:+0 added−26 removed
  • other:+61 added−70 removed

6 files+61 added−96 removed

modified:flask/app.py+31 added-34 removed
347 unmodified lines
348 #: Absolute path to the package on the filesystem. Used to look up349 #: resources contained in the package.350 root_path = None351352 def __init__(self, import_name, static_path=None, static_url_path=None,353 static_folder='static', static_host=None,354 host_matching=False, template_folder='templates',355 instance_path=None, instance_relative_config=False,356 root_path=None):357 _PackageBoundObject.__init__(self, import_name,358 template_folder=template_folder,359 root_path=root_path)360 if static_path is not None:361 from warnings import warn362 warn(DeprecationWarning('static_path is now called '363 'static_url_path'), stacklevel=2)364 static_url_path = static_path352 def __init__(353 self,354 import_name,355 static_url_path=None,356 static_folder='static',357 static_host=None,358 host_matching=False,359 template_folder='templates',360 instance_path=None,361 instance_relative_config=False,362 root_path=None363 ):364 _PackageBoundObject.__init__(365 self,366 import_name,367 template_folder=template_folder,368 root_path=root_path369 )370371 if static_url_path is not None:372 self.static_url_path = static_url_path373374 if static_folder is not None:375 self.static_folder = static_folder376377 if instance_path is None:378 instance_path = self.auto_find_instance_path()379 elif not os.path.isabs(instance_path):373 raise ValueError('If an instance path is provided it must be '374 'absolute. A relative path was given instead.')380 raise ValueError(381 'If an instance path is provided it must be absolute.'382 ' A relative path was given instead.'383 )384385 #: Holds the path to the instance folder.386 #:387 #: .. versionadded:: 0.8
13 unmodified lines
401 #: the values are the function objects themselves.402 #: To register a view function, use the :meth:`route` decorator.403 self.view_functions = {}404396 # support for the now deprecated `error_handlers` attribute. The397 # :attr:`error_handler_spec` shall be used now.398 self._error_handlers = {}399405 #: A dictionary of all registered error handlers. The key is ``None``406 #: for error handlers active on the application, otherwise the key is407 #: the name of the blueprint. Each key points to another dictionary408 #: where the key is the status code of the http exception. The
2 unmodified lines
411 #: function.412 #:413 #: To register an error handler, use the :meth:`errorhandler`414 #: decorator.410 self.error_handler_spec = {None: self._error_handlers}415 self.error_handler_spec = {}416417 #: A list of functions that are called when :meth:`url_for` raises a418 #: :exc:`~werkzeug.routing.BuildError`. Each function registered here419 #: is called with `error`, `endpoint` and `values`. If a function
135 unmodified lines
555 # For one, it might be created while the server is running (e.g. during556 # development). Also, Google App Engine stores static files somewhere557 if self.has_static_folder:558 assert bool(static_host) == host_matching, 'Invalid static_host/host_matching combination'554 self.add_url_rule(self.static_url_path + '/<path:filename>',555 endpoint='static', host=static_host,556 view_func=self.send_static_file)559 self.add_url_rule(560 self.static_url_path + '/<path:filename>',561 endpoint='static',562 host=static_host,563 view_func=self.send_static_file564 )565566 #: The click command line context for this application. Commands567 #: registered here show up in the :command:`flask` command once the568 #: application has been discovered. The default commands are
1 unmodified line
570 #:571 #: This is an instance of a :class:`click.Group` object.572 self.cli = cli.AppGroup(self.name)573566 def _get_error_handlers(self):567 from warnings import warn568 warn(DeprecationWarning('error_handlers is deprecated, use the '569 'new error_handler_spec attribute instead.'), stacklevel=1)570 return self._error_handlers571 def _set_error_handlers(self, value):572 self._error_handlers = value573 self.error_handler_spec[None] = value574 error_handlers = property(_get_error_handlers, _set_error_handlers)575 del _get_error_handlers, _set_error_handlers576574 @locked_cached_property575 def name(self):576 """The name of the application. This is usually the import name577 with the difference that it's guessed from the run file if the
1606 unmodified lines
modified:flask/helpers.py+19 added-19 removed
266 unmodified lines
267 :param _method: if provided this explicitly specifies an HTTP method.268 """269 appctx = _app_ctx_stack.top270 reqctx = _request_ctx_stack.top271272 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 )278279 # 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('.'):284285 if endpoint[:1] == '.':286 if blueprint_name is not None:287 endpoint = blueprint_name + endpoint288 else:289 endpoint = endpoint[1:]290291 external = values.pop('_external', False)292293 # Otherwise go with the url adapter from the appctx and make294 # the URLs external by default.295 else:296 url_adapter = appctx.url_adapter297298 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 )304305 external = values.pop('_external', True)306307 anchor = values.pop('_anchor', None)308 method = values.pop('_method', None)
711 unmodified lines
modified:flask/wrappers.py-17 removed
139 unmodified lines
140 #: usually a :exc:`~werkzeug.exceptions.NotFound` exception or141 #: something similar.142 routing_exception = None143144 # Switched by the request context until 1.0 to opt in deprecated145 # module functionality.146 _is_old_module = False147144 @property145 def max_content_length(self):146 """Read-only view of the ``MAX_CONTENT_LENGTH`` config key."""147 if current_app:
9 unmodified lines
157 if self.url_rule is not None:158 return self.url_rule.endpoint159160 @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.blueprint176177 @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 lines
modified:tests/test_basic.py-13 removed
1351 unmodified lines
1352 '/static/index.html'1353 rv.close()135413551356def test_static_path_deprecated(recwarn):1357 app = flask.Flask(__name__, static_path='/foo')1358 recwarn.pop(DeprecationWarning)13591360 app.testing = True1361 rv = app.test_client().get('/foo/index.html')1362 assert rv.status_code == 2001363 rv.close()13641365 with app.test_request_context():1366 assert flask.url_for('static', filename='index.html') == '/foo/index.html'136713681356def test_static_url_path():1357 app = flask.Flask(__name__, static_url_path='/foo')1358 app.testing = True1359 rv = app.test_client().get('/foo/index.html')
493 unmodified lines
modified:tests/test_deprecations.py-13 removed
7 unmodified lines
8 :copyright: (c) 2015 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""1112import pytest1312import flask131415class TestRequestDeprecation(object):
7 unmodified lines
23 return 'OK'2425 client.post('/', data='{"spam": 42}', content_type='application/json')26 recwarn.pop(DeprecationWarning)2930 def test_request_module(self, recwarn, app, client):31 """Request.module is deprecated"""3233 @app.route('/')34 def index():35 assert flask.request.module is None36 return 'OK'3738 client.get('/')39 recwarn.pop(DeprecationWarning)
modified:CHANGES+11 added
80 unmodified lines
81 exception if you don't want to traverse the MRO. (`#2362`_)82- Fix incorrect JSON encoding of aware, non-UTC datetimes. (`#2374`_)83- Template auto reloading will honor the ``run`` command's ``debug`` flag even84 if ``app.jinja_env`` was already accessed. (`#2373`_)85- The following old deprecated code was removed. (`#2385`_)8687 - ``Flask.init_jinja_globals`` - extend ``Flask.create_jinja_environment``88 instead.89 - ``Flask.error_handlers`` - tracked by ``Flask.error_handler_spec``,90 use ``@app.errorhandler`` to register handlers.91 - ``Flask.request_globals_class`` - use ``Flask.app_ctx_globals_class``92 instead.93 - ``Flask.static_path`` - use ``Flask.static_url_path`` instead.94 - ``Request.module`` - use ``Request.blueprint`` instead.9596.. _#1489: https://github.com/pallets/flask/pull/148997.. _#1621: https://github.com/pallets/flask/pull/162198.. _#1898: https://github.com/pallets/flask/pull/189899.. _#1936: https://github.com/pallets/flask/pull/1936
16 unmodified lines
116.. _#2358: https://github.com/pallets/flask/pull/2358117.. _#2362: https://github.com/pallets/flask/pull/2362118.. _#2374: https://github.com/pallets/flask/pull/2374119.. _#2373: https://github.com/pallets/flask/pull/2373120.. _#2385: https://github.com/pallets/flask/issues/2385121122Version 0.12.2123--------------124
617 unmodified lines