source: mauRepo/dj_security/trunk/dj_security/settings.py @ 8699

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

switches from a user/password login to an OpenID one.
Applies the CEDA mezzanine layout

  • Property svn:mime-type set to text/plain
Line 
1# Django settings for mydjango_secapp project.
2import os
3
4
5def decode_relative_path(rel_path):
6    return os.path.join(os.path.dirname(__file__), rel_path).replace('\\', '/') 
7
8DEBUG = True
9TEMPLATE_DEBUG = DEBUG
10
11ADMINS = (
12    # ('Your Name', 'your_email@example.com'),
13)
14MANAGERS = ADMINS
15JEEVES_URL = 'http://cidev1.jc.rl.ac.uk/dj_jeeves'
16
17
18DATABASES = {
19    'default': {
20        'ENGINE': 'django.db.backends.sqlite3',                 
21        'NAME': decode_relative_path('.') + '/sqlite.db',
22        'USER': '',                   
23        'PASSWORD': '',                     
24        'HOST': '',                     
25        'PORT': '',
26    }
27}
28"""
29
30DATABASES = {
31    # This parameters are usually set during
32    # the deployment configuration process
33    'default': {
34        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.               
35        'ENGINE': 'DB_ENGINE',
36        # Or path to database file if using sqlite3.
37        'NAME': 'DB_NAME',
38        # Not used with sqlite3.                     
39        'USER': 'DB_USER',
40        # Not used with sqlite3.                     
41        'PASSWORD': 'DB_PASSWORD',
42        # Set to empty string for localhost. Not used with sqlite3.       
43        'HOST': 'DB_HOST',                     
44        # Set to empty string for default. Not used with sqlite3.       
45        'PORT': 'DB_PORT',                     
46    }
47}
48"""
49
50OPENID_SREG = {
51    "required": ["country", "nickname", "email"],
52    "optional": "fullname"
53}
54
55
56# Local time zone for this installation. Choices can be found here:
57# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
58# although not all choices may be available on all operating systems.
59# In a Windows environment this must be set to your system time zone.
60TIME_ZONE = 'America/Chicago'
61
62# Language code for this installation. All choices can be found here:
63# http://www.i18nguy.com/unicode/language-identifiers.html
64LANGUAGE_CODE = 'en-us'
65
66SITE_ID = 1
67
68# If you set this to False, Django will make some optimizations so as not
69# to load the internationalization machinery.
70USE_I18N = True
71
72# If you set this to False, Django will not format dates, numbers and
73# calendars according to the current locale.
74USE_L10N = True
75
76# If you set this to False, Django will not use timezone-aware datetimes.
77USE_TZ = True
78
79# Absolute filesystem path to the directory that will hold user-uploaded files.
80# Example: "/home/media/media.lawrence.com/media/"
81MEDIA_ROOT = ''
82
83# URL that handles the media served from MEDIA_ROOT. Make sure to use a
84# trailing slash.
85# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
86MEDIA_URL = ''
87
88# Absolute path to the directory static files should be collected to.
89# Don't put anything in this directory yourself; store your static files
90# in apps' "static/" subdirectories and in STATICFILES_DIRS.
91# Example: "/home/media/media.lawrence.com/static/"
92STATIC_ROOT = ''
93
94# URL prefix for static files.
95# Example: "http://media.lawrence.com/static/"
96STATIC_URL = '/static/'
97
98# Additional locations of static files
99STATICFILES_DIRS = (
100    # Put strings here, like "/home/html/static" or "C:/www/django/static".
101    # Always use forward slashes, even on Windows.
102    # Don't forget to use absolute paths, not relative paths.
103)
104
105# List of finder classes that know how to find static files in
106# various locations.
107STATICFILES_FINDERS = (
108    'django.contrib.staticfiles.finders.FileSystemFinder',
109    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
110#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
111)
112
113# Make this unique, and don't share it with anybody.
114SECRET_KEY = '=+l)#o$ugq4pc14*$08q5gw(&0@nns@gm&2f=bx0_*jc1+y%w1'
115
116# List of callables that know how to import templates from various sources.
117TEMPLATE_LOADERS = (
118    'django.template.loaders.filesystem.Loader',
119    'django.template.loaders.app_directories.Loader',
120#     'django.template.loaders.eggs.Loader',
121)
122
123MIDDLEWARE_CLASSES = (
124    'django.middleware.common.CommonMiddleware',
125    'django.contrib.sessions.middleware.SessionMiddleware',
126    'django.middleware.csrf.CsrfViewMiddleware',
127    'django.contrib.auth.middleware.AuthenticationMiddleware',
128    'django.contrib.messages.middleware.MessageMiddleware',
129    'django_authopenid.middleware.OpenIDMiddleware',
130    'dj_security.middleware.DJ_Security_Middleware',
131    # Uncomment the next line for simple clickjacking protection:
132    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
133)
134
135ROOT_URLCONF = 'dj_security.urls'
136
137# Python dotted path to the WSGI application used by Django's runserver.
138#WSGI_APPLICATION = 'dj_security.wsgi.application'
139
140TEMPLATE_DIRS = (
141    decode_relative_path('static/templates')
142    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
143    # Always use forward slashes, even on Windows.
144    # Don't forget to use absolute paths, not relative paths.
145)
146
147INSTALLED_APPS = (
148    'django.contrib.auth',
149    'django.contrib.contenttypes',
150    'django.contrib.sessions',
151    'django.contrib.sites',
152    'django.contrib.messages',
153    'django.contrib.staticfiles',
154    'registration',
155    'django.contrib.humanize',
156    'django_authopenid',
157    'dj_security',
158    # Uncomment the next line to enable the admin:
159    # 'django.contrib.admin',
160    # Uncomment the next line to enable admin documentation:
161    # 'django.contrib.admindocs',
162)
163
164NOT_ENCODE = ['password', 'backend']
165SHARED_SECRET = 'sharedsecret'   
166APPLICATION_ROOT = 'PROJECT_NAME_PAR/'
167if APPLICATION_ROOT.startswith('PROJECT_NAME_'):
168    APPLICATION_ROOT = ''
169   
170# One-week activation window; you may, of course, use a different value.   
171ACCOUNT_ACTIVATION_DAYS = 7
172
173# Adds to the site framework the current machine
174# where dj_security is deployed
175import socket
176try:
177    HOSTNAME = socket.gethostname()
178except Exception:
179    HOSTNAME = 'localhost'
180from django.contrib.sites.models import Site
181from django.db.utils import DatabaseError   
182try:
183    site = Site()
184    site.name = HOSTNAME
185    site.domain = HOSTNAME + '/' + APPLICATION_ROOT
186    site.save()
187    #Sets the default site
188    SITE_ID = site.pk
189except DatabaseError as ex:
190    print str(ex)
191
192
193
194TEMPLATE_CONTEXT_PROCESSORS = (
195    'django_authopenid.context_processors.authopenid',
196    'django.core.context_processors.i18n',
197)
198
199AUTH_PROFILE_MODULE = 'dj_security.UserProfile'
200
201# A sample logging configuration. The only tangible logging
202# performed by this configuration is to send an email to
203# the site admins on every HTTP 500 error when DEBUG=False.
204# See http://docs.djangoproject.com/en/dev/topics/logging for
205# more details on how to customize your logging configuration.
206LOGGING = {
207    'version': 1,
208    'disable_existing_loggers': False,
209    'formatters': {
210        'verbose': {
211            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
212        },
213        'simple': {
214            'format': '%(levelname)s %(message)s'
215        },
216    },
217    'filters': {
218        'require_debug_false': {
219            '()': 'django.utils.log.RequireDebugFalse'
220        }
221    },
222    'handlers': {
223        'mail_admins': {
224            'level': 'ERROR',
225            'filters': ['require_debug_false'],
226            'class': 'django.utils.log.AdminEmailHandler'
227        },
228        'console':{
229            'level':'DEBUG',
230            'class':'logging.StreamHandler',
231            'formatter': 'verbose'
232        }
233    },
234    'loggers': {
235        'django.request': {
236            'handlers': ['mail_admins'],
237            'level': 'ERROR',
238            'propagate': True,
239        },
240        'dj_security': {
241            'handlers': ['console'],
242            'level': 'DEBUG',
243            'propagate': True,
244        }
245    }
246}
Note: See TracBrowser for help on using the repository browser.