Skip to content
Myr

Move python properties to decorator syntax

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

authored by Scott Crosby · committed by Scott Crosby · parent af1b2ea · 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

3 files+30 added−38 removed

modified:flask/app.py+21 added-24 removed
725 unmodified lines
726 :param mode: resource file opening mode, default is 'rb'.727 """728 return open(os.path.join(self.instance_path, resource), mode)729730 @property730 def _get_templates_auto_reload(self):731 def templates_auto_reload(self):732 """Reload templates when they are changed. Used by733 :meth:`create_jinja_environment`.734735 This attribute can be configured with :data:`TEMPLATES_AUTO_RELOAD`. If
5 unmodified lines
741 """742 rv = self.config["TEMPLATES_AUTO_RELOAD"]743 return rv if rv is not None else self.debug744745 @templates_auto_reload.setter744 def _set_templates_auto_reload(self, value):746 def templates_auto_reload(self, value):747 self.config["TEMPLATES_AUTO_RELOAD"] = value748747 templates_auto_reload = property(748 _get_templates_auto_reload, _set_templates_auto_reload749 )750 del _get_templates_auto_reload, _set_templates_auto_reload751749 def create_jinja_environment(self):750 """Create the Jinja environment based on :attr:`jinja_options`751 and the various Jinja-related methods of the app. Changing752 :attr:`jinja_options` after this will have no effect. Also adds
98 unmodified lines
851 #:852 #: Default: ``'production'``853 env = ConfigAttribute("ENV")854855 @property858 def _get_debug(self):856 def debug(self):857 """Whether debug mode is enabled. When using ``flask run`` to start858 the development server, an interactive debugger will be shown for859 unhandled exceptions, and the server will be reloaded when code860 changes. This maps to the :data:`DEBUG` config key. This is861 enabled when :attr:`env` is ``'development'`` and is overridden862 by the ``FLASK_DEBUG`` environment variable. It may not behave as863 expected if set in code.864865 **Do not enable debug mode when deploying in production.**866867 Default: ``True`` if :attr:`env` is ``'development'``, or868 ``False`` otherwise.869 """870 return self.config["DEBUG"]871872 @debug.setter861 def _set_debug(self, value):873 def debug(self, value):874 self.config["DEBUG"] = value875 self.jinja_env.auto_reload = self.templates_auto_reload876865 #: Whether debug mode is enabled. When using ``flask run`` to start866 #: the development server, an interactive debugger will be shown for867 #: unhandled exceptions, and the server will be reloaded when code868 #: changes. This maps to the :data:`DEBUG` config key. This is869 #: enabled when :attr:`env` is ``'development'`` and is overridden870 #: by the ``FLASK_DEBUG`` environment variable. It may not behave as871 #: expected if set in code.872 #:873 #: **Do not enable debug mode when deploying in production.**874 #:875 #: Default: ``True`` if :attr:`env` is ``'development'``, or876 #: ``False`` otherwise.877 debug = property(_get_debug, _set_debug)878 del _get_debug, _set_debug879877 def run(self, host=None, port=None, debug=None, load_dotenv=True, **options):878 """Runs the application on a local development server.879880 Do not use ``run()`` in a production setting. It is not intended to
1530 unmodified lines
modified:flask/ctx.py+4 added-5 removed
313 unmodified lines
314315 if self.url_adapter is not None:316 self.match_request()317318 @property318 def _get_g(self):319 def g(self):320 return _app_ctx_stack.top.g321322 @g.setter321 def _set_g(self, value):323 def g(self, value):324 _app_ctx_stack.top.g = value325324 g = property(_get_g, _set_g)325 del _get_g, _set_g326326 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 to
143 unmodified lines
modified:flask/helpers.py+5 added-9 removed
949 unmodified lines
950 #: are accessible via the :command:`flask` command once the951 #: application has been discovered and blueprints registered.952 self.cli = AppGroup()953954 @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)959960 @static_folder.setter958 def _set_static_folder(self, value):961 def static_folder(self, value):962 self._static_folder = value963961 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_folder967964 @property965 def static_url_path(self):966 """The URL prefix that the static route will be accessible from.967
145 unmodified lines