Add Flask.config_class attribute #775

Merged
merged 1 commit into from Feb 20, 2014

3 participants

@Xion

Similar to request_class, response_class and app_ctx_globals_class, the config_class attribute of Flask allows to specify custom class that stores the configuration for the app:

import flask

class Config(flask.Config):
    def __getitem__(self, key):
        try:
            return super(Config, self).__getitem__(key)
        except KeyError:
            return None

class Flask(flask.Flask):
    config_class = Config

The current alternative is to override make_config and repeat its logic (such as handling of instance_relative argument). This should be more convenient and robust.

@grampajoe

@Xion, it looks like your pull request's build fails on Python 2.6: https://travis-ci.org/mitsuhiko/flask/builds/8345645

Once the build passes, is this something the maintainers are interested in including? I think it seems useful, e.g. for adding custom app.config.from_ methods.

@DasIch DasIch merged commit ec5b182 into pallets:master Feb 20, 2014

1 check failed

Details default The Travis CI build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment