source: mauRepo/MolesManager/trunk/cedaMoles/MolesManager/settings.py @ 8573

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/cedaMoles/MolesManager/settings.py@8573
Revision 8573, 7.9 KB checked in by mnagni, 7 years ago (diff)

Incomplete - # 22554: "Remove the ""FollowSymLinks"""
 http://team.ceda.ac.uk/trac/ceda/ticket/22554

Fixes the localhost static files serving

Line 
1# Django settings for MolesManager project.
2import os
3
4
5def decodeRelativePath(relPath):
6    return os.path.join(os.path.dirname(__file__), relPath).replace('\\', '/')   
7   
8DJANGO_PROJECT = os.path.dirname(decodeRelativePath(''))
9SRC = os.path.dirname(DJANGO_PROJECT)
10PROJECT = os.path.dirname(SRC)
11
12
13DEBUG = True
14TEMPLATE_DEBUG = DEBUG
15
16ADMINS = (
17    # ('Your Name', 'your_email@example.com'),
18)
19
20SITE_ROOT = os.path.dirname(os.path.abspath(__file__))
21
22PROJECT_DIRNAME = SITE_ROOT.split(os.sep)[-1]
23
24
25MANAGERS = ADMINS
26
27DATABASES = {
28    'default': {
29        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
30        'NAME': '/sqlite.db',                      # Or path to database file if using sqlite3.
31        'USER': '',                      # Not used with sqlite3.
32        'PASSWORD': '',                  # Not used with sqlite3.
33        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
34        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
35    }
36}
37
38# Local time zone for this installation. Choices can be found here:
39# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
40# although not all choices may be available on all operating systems.
41# On Unix systems, a value of None will cause Django to use the same
42# timezone as the operating system.
43# If running in a Windows environment this must be set to the same as your
44# system time zone.
45TIME_ZONE = 'America/Chicago'
46
47# Language code for this installation. All choices can be found here:
48# http://www.i18nguy.com/unicode/language-identifiers.html
49LANGUAGE_CODE = 'en-gb'
50
51SITE_ID = 1
52
53# If you set this to False, Django will make some optimizations so as not
54# to load the internationalization machinery.
55USE_I18N = True
56
57# If you set this to False, Django will not format dates, numbers and
58# calendars according to the current locale
59USE_L10N = True
60
61# Absolute filesystem path to the directory that will hold user-uploaded files.
62# Example: "/home/media/media.lawrence.com/media/"
63MEDIA_ROOT = ''
64
65
66# URL that handles the media served from MEDIA_ROOT. Make sure to use a
67# trailing slash.
68# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
69MEDIA_URL = ''
70 
71# Absolute path to the directory static files should be collected to.
72# Don't put anything in this directory yourself; store your static files
73# in apps' "static/" subdirectories and in STATICFILES_DIRS.
74# Example: "/home/media/media.lawrence.com/static/"
75STATIC_ROOT = os.path.join(DJANGO_PROJECT, 'static')
76print STATIC_ROOT
77
78# URL prefix for static files.
79# Example: "http://media.lawrence.com/static/"
80
81#Deployment parameterized version
82#STATIC_URL = 'http://localhost'
83#STATIC_URL = 'http://127.0.0.1:8000/static/'
84#STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL)
85STATIC_URL = 'CUSTOM_STATIC_URL'
86if STATIC_URL == 'CUSTOM_STATIC_URL':
87    STATIC_URL = 'http://127.0.0.1:8000/static/'
88print STATIC_URL
89#STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL)
90
91# URL prefix for admin static files -- CSS, JavaScript and images.
92# Make sure to use a trailing slash.
93# Examples: "http://foo.com/static/admin/", "/static/admin/".
94ADMIN_MEDIA_PREFIX = '/static/admin/'
95
96# Additional locations of static files
97STATICFILES_DIRS = (
98    ()
99    # Put strings here, like "/home/html/static" or "C:/www/django/static".
100    # Always use forward slashes, even on Windows.
101    # Don't forget to use absolute paths, not relative paths.
102)
103
104# List of finder classes that know how to find static files in
105# various locations.
106STATICFILES_FINDERS = (
107    'django.contrib.staticfiles.finders.FileSystemFinder',
108    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
109    'django.contrib.staticfiles.finders.DefaultStorageFinder',
110)
111
112
113
114
115# Make this unique, and don't share it with anybody.
116SECRET_KEY = '2ttix#hi63qnw0derz&0(60&65@v=@#5gg9$9r2jw5v)nccfg+'
117
118# List of callables that know how to import templates from various sources.
119TEMPLATE_LOADERS = (
120    'django.template.loaders.filesystem.Loader',
121    'django.template.loaders.app_directories.Loader',
122#     'django.template.loaders.eggs.Loader',
123)
124
125
126
127MIDDLEWARE_CLASSES = (
128    'django.middleware.common.CommonMiddleware',
129    'django.contrib.sessions.middleware.SessionMiddleware',
130    'django.middleware.csrf.CsrfViewMiddleware',
131    'django.contrib.auth.middleware.AuthenticationMiddleware',
132    'django.contrib.messages.middleware.MessageMiddleware',
133    'molesSessionMiddleware.MolesSessionMiddleware',
134)
135ROOT_URLCONF = 'MolesManager.urls'
136
137TEMPLATE_CONTEXT_PROCESSORS = (
138    "django.contrib.auth.context_processors.auth",
139    "django.core.context_processors.debug",
140    "django.core.context_processors.i18n",
141    "django.core.context_processors.media",
142    "django.core.context_processors.request",
143    "django.core.context_processors.static",
144)
145
146
147TEMPLATE_DIRS = (
148    decodeRelativePath('static/templates')                 
149    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
150    # Always use forward slashes, even on Windows.
151    # Don't forget to use absolute paths, not relative paths.
152)
153
154INSTALLED_APPS = (
155    'django.contrib.auth',
156    'django.contrib.contenttypes',
157    'django.contrib.sessions',
158    'django.contrib.sites',
159    'django.contrib.messages',
160    'django.contrib.staticfiles',
161    'ea_model',
162    # Uncomment the next line to enable the admin:
163    # 'django.contrib.admin',
164    # Uncomment the next line to enable admin documentation:
165    # 'django.contrib.admindocs',
166        #This line defines where catch the /static/ folder
167)
168
169SITE_ROOT = DJANGO_PROJECT
170
171# A sample logging configuration. The only tangible logging
172# performed by this configuration is to send an email to
173# the site admins on every HTTP 500 error.
174# See http://docs.djangoproject.com/en/dev/topics/logging for
175# more details on how to customize your logging configuration.
176LOGGING = {
177    'version': 1,
178    'disable_existing_loggers': True,
179    'formatters': {
180        'verbose': {
181            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
182        },
183        'simple': {
184            'format': '%(levelname)s %(message)s'
185        },
186    },   
187    'handlers': {
188        'mail_admins': {
189            'level': 'ERROR',
190            'class': 'django.utils.log.AdminEmailHandler'
191        },
192        'console':{
193            'level':'DEBUG',
194            'class':'logging.StreamHandler',
195            'formatter': 'verbose'
196        }
197    },
198    'loggers': {
199        'django.request': {
200            'handlers': ['mail_admins'],
201            'level': 'ERROR',
202            'propagate': True,
203        },
204        'sqlalchemy.engine': {
205            'handlers': ['console'],
206            'level': 'WARN',
207            'propagate': True,
208        }
209    }
210}
211
212#moles3 database connection
213#MOLES3_DB_CONNECTION = 'postgresql://user:pws@host:port/dbName'
214MOLES3_DB_CONNECTION = 'PG_MOLES3_DB_CONNECTION'
215from ea_model.sqlTables import doTables as doMoles, attachEvents
216MOLES3_DB_SCRIPT = doMoles
217EVENTS_DB = attachEvents
218
219
220#moles2 to moles3 migration database connection
221#MIGRATION_DB_CONNECTION = 'postgresql://user:pws@host:port/dbName'
222MIGRATION_DB_CONNECTION = 'PG_MIGRATION_DB_CONNECTION'
223from cedaMoles.libs.migration.db.migrationTables import doTables as doMigration
224MIGRATION_DB_SCRIPT = doMigration
225
226#INFO_DB_CONNECTION = 'postgresql://user:pws@host:port/dbName'
227INFO_DB_CONNECTION = 'PG_INFO_DB_CONNECTION'
228
229if os.environ.has_key('MIGRATION_DB_CONNECTION'):
230    MIGRATION_DB_CONNECTION = os.environ['MIGRATION_DB_CONNECTION']   
231   
232if os.environ.has_key('MOLES3_DB_CONNECTION'):
233    MOLES3_DB_CONNECTION = os.environ['MOLES3_DB_CONNECTION']
234   
235if os.environ.has_key('INFO_DB_CONNECTION'):
236    INFO_DB_CONNECTION = os.environ['INFO_DB_CONNECTION'] 
237
238RUN_MIGRATION = True
239#Default to one day
240MIGRATION_INTERVAL = 86400
241
242reportMigrationTo = ['maurizio.nagni@stfc.ac.uk', 'm.nagni@gmail.com']
243
244# Local modifications to settings are imported from settings_local.py
245from cedaMoles.MolesManager.settings_local import *
Note: See TracBrowser for help on using the repository browser.