Skip to main content

A better configuration library for Django and other Python projects

Project description

Walter is a configuration library, inspired by python-decouple, and intended to replace direct access to os.environ in Django settings.py files (although it is by no means Django-specific). It currently supports Python 3.5+.

It differs from other, similar libraries for two reasons:

  • It will let you specify your configuration parameters in one place and have auto-generated Sphinx documentation, just like with Python code. (Work on this hasn’t been started yet.)

  • When your users try to start up your app with invalid configuration, the error message they get shows a list of all of the errors with every configuration parameter, not just the first one.

Installation

pip install walter

Usage

from walter.config import Config

# Your configuration needs to be wrapped in a context manager,
# so Walter can collect all the errors and display them at the end.
with Config("SGC", "Dialer") as config:

    # Read a configuration value with config.get()
    SECRET_KEY = config.get('SECRET_KEY')

    # Convert the returned value to something other than a string with cast.
    DEBUG = config.get('DEBUG', cast=bool)

    # You can pass any function that takes a string to `cast`.
    # Here, we're using a third party function to parse a database URL
    # string into a Django-compatible dictionary.
    DATABASES = {
        'default': config.get('DATABASE_URL', cast=dj_database_url.parse),
    }

    # You can also make a parameter optional by giving it a default.
    RAVEN_DSN = config.get('RAVEN_DSN', default=None)

    # Last but not least, help_text is displayed in your Sphinx docs.
    SITE_NAME = config.get('SITE_NAME',
                           help_text="Displayed to users in the admin")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

walter-0.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file walter-0.2-py3-none-any.whl.

File metadata

  • Download URL: walter-0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for walter-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4236e23306f0cb7be42cf270c89808b9f91d31d09c1a1658dbdde963a4659a6c
MD5 b4f600661d4d9a50d4ad10f0134c33b7
BLAKE2b-256 cf31360b4f1cc6a2aba658f188d88ff7ae35737a311fedf634fd4231c399074c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page