[damned-lies] Use a custom local_settings.py to customize the application



commit d8f3f603f0b75e8cf319bf9462392737751f2772
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Feb 12 10:28:04 2011 +0100

    Use a custom local_settings.py to customize the application
    
    The old scheme of copying a sample to settings.py has been changed
    to using a local_settings.py where only custom settings have to be
    defined.
    If you have an existing instance of damned-lies, rename your settings.py
    to local_settings.py, and only keep the custom settings in it.

 README                            |   16 +++++++++++-----
 languages/views.py                |    2 +-
 settings_sample.py => settings.py |   17 ++++++++++++-----
 3 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/README b/README
index 3b5b6dc..dd57505 100644
--- a/README
+++ b/README
@@ -35,7 +35,7 @@ Requirements
 
 7 - [Optional] Django Debug Toolbar
     git clone git://github.com/dcramer/django-debug-toolbar.git
-    Define USE_DEBUG_TOOLBAR to True in settings.py to use it.
+    Define USE_DEBUG_TOOLBAR to True in local_settings.py to use it.
 
 8 - [Optional] python-openid and django-openid (see OpenID support
     below).
@@ -45,11 +45,17 @@ Requirements
 Installation
 ============
 
-1 - Rename settings_sample.py to settings.py and review settings
+1 - Create a local_settings.py and overwrite settings to match your requirements
+    and your configuration layouts. Typical settings to customize include:
+    DATABASES, DEBUG, TEMPLATE_DEBUG, STATIC_SERVE, ADMINS, MANAGERS, SCRATCHDIR and
+    various EMAIL settings.
     (please refer to Database configuration below for more
     informations).
     SCRATCHDIR should point to an existing directory, writable by
     the web application user.
+    Note also that if you don't want to really send mail when testing the app, you
+    can set the EMAIL_BACKEND setting as follows to redirect mail to the console:
+    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 
 2 - Run './manage.py syncdb' then:
     ./manage.py migrate
@@ -79,8 +85,8 @@ package:
 
 git clone git://github.com/simonw/django-openid.git
 
-Put it somewhere in your Python path and uncomment 'django_openid' in
-your settings.py INSTALLED_APPS.
+Put it somewhere in your Python path and set USE_DJANGO_OPENID to True in your
+local_settings.py.
 
 This package is dependant on the python-openid package to be installed
 on your system. Run 'python manage.py syncdb' and here we go!
@@ -106,7 +112,7 @@ Create a database in UTF8, either with default-character-set = utf8
 under [mysqld] section in the my.cnf file or with an explicit 'create
 database bla charset=utf8;'
 
-In settings.py:
+In local_settings.py:
 
 DATABASES = {
     'default' {
diff --git a/languages/views.py b/languages/views.py
index fb792f6..1fea639 100644
--- a/languages/views.py
+++ b/languages/views.py
@@ -185,4 +185,4 @@ def clean_tar_files():
         return
     for tarfile in os.listdir(tar_directory):
         if not tarfile.endswith("%s.tar.gz" % date.today()):
-            os.remove(tarfile)
+            os.remove(os.path.join(tar_directory, tarfile))
diff --git a/settings_sample.py b/settings.py
similarity index 93%
rename from settings_sample.py
rename to settings.py
index 725ad22..78dc931 100644
--- a/settings_sample.py
+++ b/settings.py
@@ -7,12 +7,13 @@ DEBUG = True
 TEMPLATE_DEBUG = DEBUG
 STATIC_SERVE = True
 USE_DEBUG_TOOLBAR = False
+USE_DJANGO_OPENID = False
 
 PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
+PROJECT_NAME = PROJECT_PATH.split('/')[-1]
 
 ADMINS = (
-    ('Claude Paroz', 'claude 2xlibre net'),
-    ('Stephane Raimbault', 'stephane raimbault gmail com'),
+    ('Your Name', 'your_address example org'),
 )
 
 MANAGERS = ADMINS
@@ -101,8 +102,7 @@ MIDDLEWARE_CLASSES = (
     'django.middleware.transaction.TransactionMiddleware',
 )
 
-# Make sure to change 'damned-lies' to match your site's name
-ROOT_URLCONF = 'damned-lies.urls'
+ROOT_URLCONF = '%s.urls' % PROJECT_NAME
 
 TEMPLATE_DIRS = (
     os.path.join(PROJECT_PATH, 'templates'),
@@ -117,7 +117,6 @@ INSTALLED_APPS = (
     'django.contrib.humanize',
     'django.contrib.markup',
     'django.contrib.messages',
-#    'django_openid',
     'south',
     'common',
     'languages',
@@ -132,6 +131,14 @@ INTERNAL_IPS=('127.0.0.1',)
 
 MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
 
+try:
+    from local_settings import *
+except ImportError:
+    pass
+
 if USE_DEBUG_TOOLBAR:
     MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
     INSTALLED_APPS += ('debug_toolbar',)
+
+if USE_DJANGO_OPENID:
+    INSTALLED_APPS += ('django_openid',)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]