Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 1ebcfe4cecdfe825fe9b104c034cb09022e8c95e @elijahr elijahr committed Oct 14, 2011
@@ -0,0 +1,4 @@
+build/*
+dist/*
+*.pyc
+*.egg-info/*
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Sanders New Media
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,32 @@
+[django-host-settings](http://github.com/sandersnewmedia/django-host-settings)
+================================================================================
+
+Overview
+--------
+django-host-settings is a small Django app which lets you easily manage settings for your development machines & servers.
+
+Installation
+------------
+ $ sudo easy_install django-host-settings
+
+Or...
+
+ $ git clone git://github.com/sandersnewmedia/django-host-settings.git
+ $ cd django-host-settings
+ $ python setup.py install
+
+Usage
+-----
+In your settings.py:
+
+ INSTALLED_APPS = (
+ ...
+ 'django_host_settings'
+ )
+
+Then run these commands:
+
+ $ python manage.py createhostsettings
+ $ echo "\n\nfrom django_host_settings.settings import *" > settings.py
+
+You can now override any settings in your own settings file, created in the config/ directory.
@@ -0,0 +1,7 @@
+
+def get_local_settings_module():
+ from socket import gethostname
+ import re
+ non_word_re = re.compile('[^\w]')
+ # get a filename-safe version of the system's hostname
+ return non_word_re.sub('_', gethostname())
@@ -0,0 +1,21 @@
+from django.core.management.base import BaseCommand, CommandError
+from django_host_settings import get_local_settings_module
+from django.conf import settings
+import os
+
+class Command(BaseCommand):
+ help = 'Creates a host settings file'
+
+ def handle(self, *args, **options):
+ module_name = get_local_settings_module()
+ module_path = os.path.join(settings.PROJECT_ROOT, 'config',
+ '%s.py' % module_name)
+ if os.path.exists(module_path):
+ raise CommandError('%s already exists, nothing to do' % module_path)
+ try:
+ with open(module_path, 'w+b') as f:
+ f.write('DEBUG = True\n')
+ except Exception as e:
+ raise CommandError('Error writing to %s: %s' % (module_path, str(e)))
+
+ self.stdout.write('Wrote local settings to %s\n' % module_path)
@@ -0,0 +1,15 @@
+
+from django_host_settings import get_local_settings_module
+
+LOCAL_SETTINGS_MODULE = get_local_settings_module()
+
+try:
+ # import the configuration settings file
+ config_module = __import__('config.%s' % LOCAL_SETTINGS_MODULE, globals(), locals(), 'foo')
+
+ # Load the config settings properties into the local scope.
+ for setting in dir(config_module):
+ if setting == setting.upper():
+ locals()[setting] = getattr(config_module, setting)
+except ImportError:
+ pass
@@ -0,0 +1,5 @@
+from setuptools import setup
+
+setup(name='django_host_settings',
+ packages=['django_host_settings']
+)

0 comments on commit 1ebcfe4

Please sign in to comment.