-
Website
http://blog.bitquabit.com/ -
Original page
http://blog.bitquabit.com/2009/10/02/local_settingspy-considered-harmful/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
Grr
4 comments · 1 points
-
Eli James
2 comments · 3 points
-
Aupajo
3 comments · 6 points
-
intellectualhonesty
2 comments · 2 points
-
tomtomtomtomtom
2 comments · 2 points
-
-
Popular Threads
- virtualenv
- proj_dir
-- django_site
---- settings.py
-- host1.local_settings.py
-- host2.local_settings.py
-- fabfile.py
My fabfile deployment rules transfer the appropriate local_settings.py file for the host I'm deploying to - and everything is under version control...
You can either set this password using your OS tools (e.g. Keychain on Mac OS X lets you add new keychain entries from a GUI), or set the password programmatically from an interactive session:
>>> import keyring
>>> keyring.set_password('django-app-name','fred','abc123')
Then, in your settings.py, read the password from the keychain with:
>>> import keyring
>>> password = keyring.get_password('django-app-name','fred')
I've been using this to secure my password for development environments on Mac OS X, and production environments on Linux (RHEL 4 and CentOS 5). Works great!
http://pypi.python.org/pypi/keyring
For instance, if I have host my staging environment and demo environment on the same EC2 host to save money, they will both have the same hostname.
Additionally, what happens when I have to scale up my production environment to multiple machines, each which will have a different hostname. One simple workaround in this case is to simply copy my production settings to prodserver1.py, prodserver2.py, etc.--but this approach would violate DRY.
In the case of the second, though, you don't actually need to violate DRY. If your VCS supports symlinks, you just make a single deploy.py and then symlink it to the machine names. Alternatively, since you probably have a
fabfile.pyalready to manage deployment, and that has a list of servers, you could just modify your__init__.pyscript to check the same list to determine whether to use the server deployment settings or not.