forked from orbit-oss/flask
Merge branch 'master' of https://github.com/Xion/flask into Xion-master
Conflicts: flask/testsuite/config.py
This commit is contained in:
commit
66e51d5be7
3 changed files with 23 additions and 1 deletions
11
flask/app.py
11
flask/app.py
|
|
@ -175,6 +175,15 @@ class Flask(_PackageBoundObject):
|
||||||
_set_request_globals_class)
|
_set_request_globals_class)
|
||||||
del _get_request_globals_class, _set_request_globals_class
|
del _get_request_globals_class, _set_request_globals_class
|
||||||
|
|
||||||
|
#: The class that is used for the ``config`` attribute of this app.
|
||||||
|
#: Defaults to :class:`~flask.Config`.
|
||||||
|
#:
|
||||||
|
#: Example use cases for a custom class:
|
||||||
|
#:
|
||||||
|
#: 1. Default values for certain config options.
|
||||||
|
#: 2. Access to config values through attributes in addition to keys.
|
||||||
|
config_class = Config
|
||||||
|
|
||||||
#: The debug flag. Set this to `True` to enable debugging of the
|
#: The debug flag. Set this to `True` to enable debugging of the
|
||||||
#: application. In debug mode the debugger will kick in when an unhandled
|
#: application. In debug mode the debugger will kick in when an unhandled
|
||||||
#: exception occurs and the integrated server will automatically reload
|
#: exception occurs and the integrated server will automatically reload
|
||||||
|
|
@ -610,7 +619,7 @@ class Flask(_PackageBoundObject):
|
||||||
root_path = self.root_path
|
root_path = self.root_path
|
||||||
if instance_relative:
|
if instance_relative:
|
||||||
root_path = self.instance_path
|
root_path = self.instance_path
|
||||||
return Config(root_path, self.default_config)
|
return self.config_class(root_path, self.default_config)
|
||||||
|
|
||||||
def auto_find_instance_path(self):
|
def auto_find_instance_path(self):
|
||||||
"""Tries to locate the instance path if it was not provided to the
|
"""Tries to locate the instance path if it was not provided to the
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,9 @@ class FlaskTestCase(unittest.TestCase):
|
||||||
def assert_not_in(self, x, y):
|
def assert_not_in(self, x, y):
|
||||||
self.assertNotIn(x, y)
|
self.assertNotIn(x, y)
|
||||||
|
|
||||||
|
def assert_isinstance(self, obj, cls):
|
||||||
|
self.assertIsInstance(obj, cls)
|
||||||
|
|
||||||
if sys.version_info[:2] == (2, 6):
|
if sys.version_info[:2] == (2, 6):
|
||||||
def assertIn(self, x, y):
|
def assertIn(self, x, y):
|
||||||
assert x in y, "%r unexpectedly not in %r" % (x, y)
|
assert x in y, "%r unexpectedly not in %r" % (x, y)
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,16 @@ class ConfigTestCase(FlaskTestCase):
|
||||||
self.assert_true(0, 'expected config')
|
self.assert_true(0, 'expected config')
|
||||||
self.assert_false(app.config.from_json('missing.json', silent=True))
|
self.assert_false(app.config.from_json('missing.json', silent=True))
|
||||||
|
|
||||||
|
def test_custom_config_class(self):
|
||||||
|
class Config(flask.Config):
|
||||||
|
pass
|
||||||
|
class Flask(flask.Flask):
|
||||||
|
config_class = Config
|
||||||
|
app = Flask(__name__)
|
||||||
|
self.assert_isinstance(app.config, Config)
|
||||||
|
app.config.from_object(__name__)
|
||||||
|
self.common_object_test(app)
|
||||||
|
|
||||||
def test_session_lifetime(self):
|
def test_session_lifetime(self):
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
app.config['PERMANENT_SESSION_LIFETIME'] = 42
|
app.config['PERMANENT_SESSION_LIFETIME'] = 42
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue