- Stores configurations and are retrievable as a dictionary
- Configurations are lazily loaded and are cached per request
- Configurations can have a Setup action to run a setup function. Configforms will follow HttpRequests returned from that function.
- Configuration is defined as a django form
- Configurations can be encrypted by registering a Configform as an AESEncryptedConfiguration
- Add the 'configstore' directory to your Python path
- Add 'configstore' to your INSTALLED_APPS in your settings file
Define your configuration form somewhere:
from django import forms
from django.contrib.auth.models import User
from configstore.forms import ConfigurationForm
class ExampleConfigurationForm(ConfigurationForm):
amount = forms.DecimalField()
message = forms.CharField()
user = forms.ModelChoiceField(queryset=User.objects.all())
def config_task(self):
return HttpResponseRedirect('/exampleform/configuration/')
Register the form:
from configstore.configs import ConfigurationInstance, register
complex_instance = ConfigurationInstance('example', 'Example Config', ExampleConfigurationForm)
register(complex_instance)
You can instead encrypt the data in your configstore data section using a different Configuration:
from configstore.configs import AESEncryptedConfiguration, register
complex_instance = AESEncryptedConfiguration('example', 'Example Config', ExampleConfigurationForm)
register(complex_instance)
Somewhere else in your code retrieve the config and use it:
from configstore.configs import get_config
config = get_config('example')
print config['amount']