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 Distribution

walter-0.3.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

walter-0.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file walter-0.3.tar.gz.

File metadata

  • Download URL: walter-0.3.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.0 Darwin/19.4.0

File hashes

Hashes for walter-0.3.tar.gz
Algorithm Hash digest
SHA256 dc8150b0079a8e8e69386f2c6a389e48f66c75fb8eed4a8aec9ef91aea3f3bd9
MD5 c328b43e27d0c19f4177d13220742381
BLAKE2b-256 f9bea4f861a6b5d8149ef085ee9d875d5930d287807ef403e45468e66a578086

See more details on using hashes here.

File details

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

File metadata

  • Download URL: walter-0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.0 Darwin/19.4.0

File hashes

Hashes for walter-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2c597110f321d316e0bd2974c282e212d03487e3c64a01a9b8eaa07d778d866d
MD5 fdce2c172ce8029dfd50dd36b918884b
BLAKE2b-256 c0fb6cb10be6bdaede6914466abd3b022b52829f4f08da8a53ccde5232797305

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