Merge pull request #3237 from scrosby/fix-3218
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Move python properties to decorator syntax
authored by David Lord · committed by GitHub · parents 91e53da, 55ad09c · Browse files · 3 files·+30 added−38 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+30 added−38 removed
- other:+30 added−38 removed
Provenance
- Commit
cd4023d- Tree
b7310b1- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
91e53da- Parent 2
55ad09c
3 files changed+30 added−38 removed
modified:flask/app.py+21 added-24 removed
726 unmodified lines727 :param mode: resource file opening mode, default is 'rb'.728 """729 return open(os.path.join(self.instance_path, resource), mode)730 731+ @property731- def _get_templates_auto_reload(self):732+ def templates_auto_reload(self):733 """Reload templates when they are changed. Used by734 :meth:`create_jinja_environment`.735 736 This attribute can be configured with :data:`TEMPLATES_AUTO_RELOAD`. If5 unmodified lines742 """743 rv = self.config["TEMPLATES_AUTO_RELOAD"]744 return rv if rv is not None else self.debug745 746+ @templates_auto_reload.setter745- def _set_templates_auto_reload(self, value):747+ def templates_auto_reload(self, value):748 self.config["TEMPLATES_AUTO_RELOAD"] = value749 748- templates_auto_reload = property(749- _get_templates_auto_reload, _set_templates_auto_reload750- )751- del _get_templates_auto_reload, _set_templates_auto_reload752-750 def create_jinja_environment(self):751 """Create the Jinja environment based on :attr:`jinja_options`752 and the various Jinja-related methods of the app. Changing753 :attr:`jinja_options` after this will have no effect. Also adds98 unmodified lines852 #:853 #: Default: ``'production'``854 env = ConfigAttribute("ENV")855 856+ @property859- def _get_debug(self):857+ def debug(self):858+ """Whether debug mode is enabled. When using ``flask run`` to start859+ the development server, an interactive debugger will be shown for860+ unhandled exceptions, and the server will be reloaded when code861+ changes. This maps to the :data:`DEBUG` config key. This is862+ enabled when :attr:`env` is ``'development'`` and is overridden863+ by the ``FLASK_DEBUG`` environment variable. It may not behave as864+ expected if set in code.865+866+ **Do not enable debug mode when deploying in production.**867+868+ Default: ``True`` if :attr:`env` is ``'development'``, or869+ ``False`` otherwise.870+ """871 return self.config["DEBUG"]872 873+ @debug.setter862- def _set_debug(self, value):874+ def debug(self, value):875 self.config["DEBUG"] = value876 self.jinja_env.auto_reload = self.templates_auto_reload877 866- #: Whether debug mode is enabled. When using ``flask run`` to start867- #: the development server, an interactive debugger will be shown for868- #: unhandled exceptions, and the server will be reloaded when code869- #: changes. This maps to the :data:`DEBUG` config key. This is870- #: enabled when :attr:`env` is ``'development'`` and is overridden871- #: by the ``FLASK_DEBUG`` environment variable. It may not behave as872- #: expected if set in code.873- #:874- #: **Do not enable debug mode when deploying in production.**875- #:876- #: Default: ``True`` if :attr:`env` is ``'development'``, or877- #: ``False`` otherwise.878- debug = property(_get_debug, _set_debug)879- del _get_debug, _set_debug880-878 def run(self, host=None, port=None, debug=None, load_dotenv=True, **options):879 """Runs the application on a local development server.880 881 Do not use ``run()`` in a production setting. It is not intended to1537 unmodified linesmodified:flask/ctx.py+4 added-5 removed
313 unmodified lines314 315 if self.url_adapter is not None:316 self.match_request()317 318+ @property318- def _get_g(self):319+ def g(self):320 return _app_ctx_stack.top.g321 322+ @g.setter321- def _set_g(self, value):323+ def g(self, value):324 _app_ctx_stack.top.g = value325 324- g = property(_get_g, _set_g)325- del _get_g, _set_g326-326 def copy(self):327 """Creates a copy of this request context with the same request object.328 This can be used to move a request context to a different greenlet.329 Because the actual request object is the same this cannot be used to143 unmodified linesmodified:flask/helpers.py+5 added-9 removed
949 unmodified lines950 #: are accessible via the :command:`flask` command once the951 #: application has been discovered and blueprints registered.952 self.cli = AppGroup()953 954+ @property954- def _get_static_folder(self):955+ def static_folder(self):956+ """The absolute path to the configured static folder."""957 if self._static_folder is not None:958 return os.path.join(self.root_path, self._static_folder)959 960+ @static_folder.setter958- def _set_static_folder(self, value):961+ def static_folder(self, value):962 self._static_folder = value963 961- static_folder = property(962- _get_static_folder,963- _set_static_folder,964- doc="The absolute path to the configured static folder.",965- )966- del _get_static_folder, _set_static_folder967-964 @property965 def static_url_path(self):966 """The URL prefix that the static route will be accessible from.967 145 unmodified lines