Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An application to allow for other apps to easily store site based configurations

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 configstore
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 requirements.txt
Octocat-spinner-32 setup.py
README.rst

Config Store

  • 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 subclassing EncryptedConfigurationForm

Installation

  1. Add the 'configstore' directory to your Python path
  2. Add 'configstore' to your INSTALLED_APPS in your settings file

Usage

Define your configuration form somewhere:

from django import forms
from django.contrib.auth.models import User

from configstore.configs import ConfigurationInstance, register
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 "Yay, you've accomplished nothing!"

Register the form:

complex_instance = ConfigurationInstance('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']

You can also encrypt the data in your configstore data section. Configstore uses AES keyed on your django secret:

from django import forms
from django.contrib.auth.models import User

from configstore.configs import ConfigurationInstance, register
from configstore.forms import EncryptedConfigurationForm

class ExampleConfigurationForm(EncryptedConfigurationForm):
    amount = forms.DecimalField()
    message = forms.CharField()
    user = forms.ModelChoiceField(queryset=User.objects.all())

    def config_task(self):
        return "Yay, you've accomplished nothing!"
Something went wrong with that request. Please try again.