changeset 171:c47bdd30a074 draft

Updated settings to python-django >= 1.2 and splitted into two files: - settings.py == deployment independent settings - settings_local.py == deployment dependent settings
author eriol-guest
date Thu, 07 Jul 2011 05:49:27 +0000
parents e7a9a76fcc46
children 16c289c44acc
files bts_webui/settings.py bts_webui/settings_local.template
diffstat 2 files changed, 57 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/bts_webui/settings.py
+++ b/bts_webui/settings.py
@@ -1,8 +1,11 @@
 # -*- coding: utf-8 -*-
-# Django settings for debbugs_ui project.
+# Django settings for bts_webui project. Settings are splitted into two files,
+# this one and settings_local.py.
 
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
+import os
+import sys
+
+BTS_WEBUI_ROOT = os.path.abspath(os.path.dirname(__file__))
 
 # Specific settings for Amancay
 DEFAULT_FROM_EMAIL = 'webmaster@marga.com.ar'
@@ -17,20 +20,15 @@
 
 MANAGERS = ADMINS
 
-DATABASE_ENGINE = 'sqlite3'           # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
-DATABASE_NAME = '.bts_webui'             # Or path to database file if using sqlite3.
-DATABASE_USER = ''             # Not used with sqlite3.
-DATABASE_PASSWORD = ''         # Not used with sqlite3.
-DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
-
-# Local time zone for this installation. All choices can be found here:
-# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
 TIME_ZONE = 'America/Argentina/Buenos_Aires'
 
 # Language code for this installation. All choices can be found here:
-# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
-# http://blogs.law.harvard.edu/tech/stories/storyReader$15
+# http://www.i18nguy.com/unicode/language-identifiers.html
 LANGUAGE_CODE = 'en-us'
 
 SITE_ID = 1
@@ -39,6 +37,10 @@
 # to load the internationalization machinery.
 USE_I18N = True
 
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale
+USE_L10N = True
+
 # Absolute path to the directory that holds media.
 # Example: "/home/media/media.lawrence.com/"
 MEDIA_ROOT = ''
@@ -52,25 +54,25 @@
 # Examples: "http://foo.com/media/", "/media/".
 ADMIN_MEDIA_PREFIX = '/media/'
 
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = '8-itje(_*=&bva=$^_*#_c$x1lp$v)ujdsp+)%o2w%x_me3ju4'
-
 # List of callables that know how to import templates from various sources.
 TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.load_template_source',
-    'django.template.loaders.app_directories.load_template_source',
-#     'django.template.loaders.eggs.load_template_source',
+'django.template.loaders.filesystem.Loader',
+'django.template.loaders.app_directories.Loader',
+#     'django.template.loaders.eggs.Loader',
 )
 
 TEMPLATE_CONTEXT_PROCESSORS = (
-    'django.core.context_processors.auth',
+    'django.contrib.auth.context_processors.auth',
     'django.core.context_processors.debug',
+    'django.core.context_processors.i18n',
+    'django.core.context_processors.media',
     'django.core.context_processors.request',
 )
 
 MIDDLEWARE_CLASSES = (
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.middleware.doc.XViewMiddleware',
 )
@@ -78,11 +80,11 @@
 ROOT_URLCONF = 'bts_webui.urls'
 
 TEMPLATE_DIRS = (
-# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
-# Always use forward slashes, even on Windows.
-# Don't forget to use absolute paths, not relative paths.
-"amancay/templates/",
-"templates/"
+    # Put strings here, like "/home/html/django_templates".
+    # Always use forward slashes.
+    # Don't forget to use absolute paths, not relative paths.
+    "amancay/templates/",
+    os.path.join(BTS_WEBUI_ROOT, 'templates'),
 )
 
 INSTALLED_APPS = (
@@ -95,3 +97,13 @@
     'registration',
     'bts_webui.amancay',
 )
+
+# Import local settings where are defined deployment dependant settings.
+# SECRET_KEY must be set in local settings to avoid sharing it in VCS.
+try:
+    from settings_local import *
+except ImportError:
+    from django.utils.termcolors import colorize
+    msg = 'Unable to find settings_local.py.'
+    sys.stderr.write(colorize(text=msg, fg='red', opts=('bold',)))
+    sys.exit(1)
new file mode 100644
--- /dev/null
+++ b/bts_webui/settings_local.template
@@ -0,0 +1,19 @@
+# Template for local settings of your project. Copy to  settings_local.py and
+# make your necessary changes.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': '',                      # Or path to database file if using sqlite3.
+        'USER': '',                      # Not used with sqlite3.
+        'PASSWORD': '',                  # Not used with sqlite3.
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
+    }
+}
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '<Set this to a random string: the longer, the better!>'