Skip to content
Myr

Add Flask.config_class feature

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

authored by Karol Kuczmarski · committed by Karol Kuczmarski · parent 88b74b3 · Browse files · 3 files+23 added−1 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+23 added−1 removed

  • other:+23 added−1 removed

3 files+23 added−1 removed

modified:flask/testsuite/__init__.py+3 added
155 unmodified lines
156157 def assert_not_in(self, x, y):158 self.assertNotIn(x, y)159160 def assert_isinstance(self, obj, cls):161 self.assertIsInstance(obj, cls)162163 if sys.version_info[:2] == (2, 6):164 def assertIn(self, x, y):165 assert x in y, "%r unexpectedly not in %r" % (x, y)166
83 unmodified lines
modified:flask/testsuite/config.py+10 added
97 unmodified lines
98 else:99 self.assert_true(0, 'expected config')100 self.assert_false(app.config.from_pyfile('missing.cfg', silent=True))101102 def test_custom_config_class(self):103 class Config(flask.Config):104 pass105 class Flask(flask.Flask):106 config_class = Config107 app = Flask(__name__)108 self.assert_isinstance(app.config, Config)109 app.config.from_object(__name__)110 self.common_object_test(app)111112 def test_session_lifetime(self):113 app = flask.Flask(__name__)114 app.config['PERMANENT_SESSION_LIFETIME'] = 42115 self.assert_equal(app.permanent_session_lifetime.seconds, 42)
194 unmodified lines
modified:flask/app.py+10 added-1 removed
173 unmodified lines
174 request_globals_class = property(_get_request_globals_class,175 _set_request_globals_class)176 del _get_request_globals_class, _set_request_globals_class177178 #: The class that is used for the ``config`` attribute of this app.179 #: Defaults to :class:`~flask.Config`.180 #:181 #: Example use cases for a custom class:182 #:183 #: 1. Default values for certain config options.184 #: 2. Access to config values through attributes in addition to keys.185 config_class = Config186187 #: The debug flag. Set this to `True` to enable debugging of the188 #: application. In debug mode the debugger will kick in when an unhandled189 #: exception occurs and the integrated server will automatically reload190 #: the application if changes in the code are detected.
426 unmodified lines
617 """618 root_path = self.root_path619 if instance_relative:620 root_path = self.instance_path612 return Config(root_path, self.default_config)621 return self.config_class(root_path, self.default_config)622623 def auto_find_instance_path(self):624 """Tries to locate the instance path if it was not provided to the625 constructor of the application class. It will basically calculate
1226 unmodified lines