-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance the settings file, use PROJECT_DIR instead of hacking with en…
…vironment variables.
- Loading branch information
1 parent
e055caa
commit db83a3d
Showing
1 changed file
with
26 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# Django settings for openshift project. | ||
import os | ||
from re import search | ||
|
||
# a setting to determine whether we are running on OpenShift | ||
ON_OPENSHIFT = False | ||
if os.environ.has_key('OPENSHIFT_REPO_DIR'): | ||
ON_OPENSHIFT = True | ||
|
||
PROJECT_DIR = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
DEBUG = True | ||
TEMPLATE_DEBUG = DEBUG | ||
|
||
ADMINS = ( | ||
# ('Your Name', '[email protected]'), | ||
) | ||
|
||
# this snippet will determine if we are running on OpenShift | ||
ON_OPENSHIFT = False | ||
environ_keys = os.environ.keys() | ||
for key in environ_keys: | ||
if search("OPENSHIFT_REPO_DIR", key): | ||
ON_OPENSHIFT = True | ||
|
||
MANAGERS = ADMINS | ||
|
||
if ON_OPENSHIFT: | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | ||
'NAME': os.environ['OPENSHIFT_DATA_DIR'] + '/sqlite3.db', # 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. | ||
} | ||
} | ||
|
||
else: | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': 'sqlite3.db', | ||
'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. | ||
} | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | ||
'NAME': os.path.join(PROJECT_DIR, 'sqlite3.db'), # 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. | ||
} | ||
} | ||
|
||
# Local time zone for this installation. Choices can be found here: | ||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | ||
|
@@ -78,7 +64,7 @@ | |
# Don't put anything in this directory yourself; store your static files | ||
# in apps' "static/" subdirectories and in STATICFILES_DIRS. | ||
# Example: "/home/media/media.lawrence.com/static/" | ||
STATIC_ROOT = '' | ||
STATIC_ROOT = os.path.join(PROJECT_DIR, '..', 'static') | ||
|
||
# URL prefix for static files. | ||
# Example: "http://media.lawrence.com/static/" | ||
|
@@ -101,7 +87,7 @@ | |
STATICFILES_FINDERS = ( | ||
'django.contrib.staticfiles.finders.FileSystemFinder', | ||
'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
#'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
) | ||
|
||
# Make this unique, and don't share it with anybody. | ||
|
@@ -111,7 +97,7 @@ | |
TEMPLATE_LOADERS = ( | ||
'django.template.loaders.filesystem.Loader', | ||
'django.template.loaders.app_directories.Loader', | ||
# 'django.template.loaders.eggs.Loader', | ||
#'django.template.loaders.eggs.Loader', | ||
) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
|
@@ -124,17 +110,12 @@ | |
|
||
ROOT_URLCONF = 'openshift.urls' | ||
|
||
if ON_OPENSHIFT: | ||
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. | ||
os.environ['OPENSHIFT_REPO_DIR'] + "/wsgi/openshift/templates" | ||
) | ||
else: | ||
TEMPLATE_DIRS = ( | ||
os.environ['PWD'] + "/templates", | ||
) | ||
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. | ||
os.path.join(PROJECT_DIR, 'templates'), | ||
) | ||
|
||
INSTALLED_APPS = ( | ||
'django.contrib.auth', | ||
|