[Chicago] Per virtualenv environment variables
Jeff Hinrichs - DM&T
jeffh at dundeemt.com
Wed Jun 27 04:51:52 CEST 2012
On Sat, Jun 23, 2012 at 8:47 AM, Adam "Cezar" Jenkins <
emperorcezar at gmail.com> wrote:
> At work I'm working on a new infrastructure. For various reasons, I really
> like how Heroku does app local settings, but can't use Heroku. They are set
> in the environment variables. For instance, I would use the Heroku command
> like so
> heroku config:add aws_key=1234567890
> and I could pull that in side my Django settings file with env['aws_key']
> So I've been wondering what the best way is to set environment variables
> on a per virtualenv case? So far I've only come up with a custom activate
> script, or code in my Django app that updates the env dictionary using a
> .cfg or .yml file found in the virtualenv. I'm sure there's some python or
> bash magic that would make it easier?
> I use YamJam, a yaml config file setup. I work in a corp environment, so
lots of my settings are the same for different projects, i.e. where is the
accounting data, where are pdfs stored, etc. So I end up with a system
that uses config settings at a user level and then project specific, or
overrides at the project level (machine or debug/production specific).
~/.yamjam/config.yaml + project/config.yaml
I like YamJam because it's just a light layer over pyyaml that handles
config setting merging intelligently.
May not be what you are looking for, but it would save you from
re-inventing your .cfg/.yml code to update settings.py.
Django needs some work there, storing db credentials and SECRET_KEY in a
piece of code that needs to be in a repository is troublesome.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chicago