Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
This repository was archived by the owner on May 1, 2020. It is now read-only.

[django-configurations] Values not evaluated with Python 2.7 #11

@pydanny

Description

@pydanny

The values that are given to dj-libcloud from the settings files are configuration value objects, not strings. This causes all kinds of problems. Current mitigation is to replace SecretValues interacting with dj-libcloud with get_env_variable functions:

# Normally you should not import ANYTHING from Django directly
# into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured

def get_env_variable(var_name):
    """Get the environment variable or return exception."""
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = "Set the %s environment variable" % var_name
        raise ImproperlyConfigured(error_msg)

class Production(Common):
    AWS_ACCESS_KEY_ID = get_env_variable("DJANGO_AWS_ACCESS_KEY_ID")
    AWS_SECRET_ACCESS_KEY = get_env_variable("DJANGO_AWS_SECRET_ACCESS_KEY")
    AWS_STORAGE_BUCKET_NAME = get_env_variable("DJANGO_AWS_STORAGE_BUCKET_NAME")

Ping @jezdez.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions