flask_waffleconf.core

class flask_waffleconf.core.WaffleConf(app=None, configstore=None)

Bases: object

Initialize the Flask-WaffleConf extension

Parameters:
  • app – Flask application instance
  • configstore (WaffleStore) – database store.
state

_WaffleState

Direct access to the initialized state object.

init_app(app, configstore)

Initialize the extension for the given application and store.

Parse the configuration values stored in the database obtained from the WAFFLE_CONFS value of the configuration.

Parameters:
  • app – Flask application instance
  • configstore (WaffleStore) – database store.
class flask_waffleconf.core._WaffleState(app, configstore)

Bases: object

Store configstore for the app state.

This object will update its application’s configuration and if the WAFFLE_MULTIPROC setting is set to True, it will also notify other processes using Redis channel or file timestamp.

Parameters:
  • app – Flask application instance.
  • configstore (WaffleStore) – database store.
parse_conf(keys=[])

Parse configuration values from the database.

The extension must have been previously initialized.

If a key is not found in the database, it will be created with the default value specified.

Parameters:keys (list[str]) – list of keys to parse. If the list is empty, then all the keys known to the application will be used.
Returns:dict of the parsed config values.
update_conf()

Update configuration values from database.

This method should be called when there is an update notification.

update_db(new_values)

Update database values and application configuration.

The provided keys must be defined in the WAFFLE_CONFS setting.

Parameters:new_values (dict) –

dict of configuration variables and their values The dict has the following structure:

{
‘MY_CONFIG_VAR’ : <CONFIG_VAL>, ‘MY_CONFIG_VAR1’ : <CONFIG_VAL1>

}