Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 1ebcfe4cecdfe825fe9b104c034cb09022e8c95e 0 parents
@elijahr elijahr authored
4 .gitignore
@@ -0,0 +1,4 @@
+build/*
+dist/*
+*.pyc
+*.egg-info/*
19 LICENSE
@@ -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.
32 README.md
@@ -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.
7 django_host_settings/__init__.py
@@ -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  django_host_settings/management/__init__.py
No changes.
0  django_host_settings/management/commands/__init__.py
No changes.
21 django_host_settings/management/commands/createhostsettings.py
@@ -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)
15 django_host_settings/settings.py
@@ -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
5 setup.py
@@ -0,0 +1,5 @@
+from setuptools import setup
+
+setup(name='django_host_settings',
+ packages=['django_host_settings']
+)
Please sign in to comment.
Something went wrong with that request. Please try again.