I'm currently learning Flask and I just set up a config file I load into the app with:
app.config.from_object('myconfigmodule')
The config module has two classes in it, Config and DebugConfig and DebugConfig inherits Config. I'd like to use @property getters to get config variables rather than accessing them with app.config['myvar']
because it makes for cleaner code. I set this up and app.config does not see the properties but I can still access the config class members with app.config['myvar']
This is the error I get when I start my app:
Traceback (most recent call last):
File "runserver.py", line 3, in <module>
app.run(host=app.config['_APP_HOST'], debug=app.config.Debug)
AttributeError: 'Config' object has no attribute 'Debug'
In the config class the Debug property is as follows:
class Config (object):
_APP_DEBUG = False
@property
def Debug (self):
return self._APP_DEBUG
Am I doing something wrong here or does Flask just not like properties in configs for some reason? Thanks for any help!