Application Config
Base class for the running application's configuration. By convention
all configuration parameters should be specified here in one payload.
You'll often call your subclass ConfigBase
.
Users are responsible for instantiating an AppConfig with your desired settings. This instance will be registered into the global space so it's accessible to your controllers. An error will be thrown if you attempt to instantiate more than one AppConfig.
Class Attributes
- Name
PACKAGE
- Type
- str | None
- Description
- Name
ENVIRONMENT
- Type
- str
- Description
- Name
model_config
- Type
- Description
get_config
Get the current configuration instance that's registered globally. Will throw an error if no configuration instance is registered.
Internal Functions
Used in unit testing or some other scenarios where you need specific control over the configuration that is mounted into the global registry.
register_config
Manually register a configuration instance into the global space. Each application can have a maximum of one configuration instance registered. If you attempt to register a second instance, an error will be thrown.
Registration should happen automatically by initializing a new instance of your ConfigBase class on application start. This auto-registration is provided by the configuration's metaclass in ConfigMeta.
Parameters
- Name
config
- Type
- ConfigBase
- Description
unregister_config
Unregister the current configuration instance.