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

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

Changes the login openID 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_AX = [
51    'http://axschema.org/contact/email'
52]
53
54
55# Local time zone for this installation. Choices can be found here:
56# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
57# although not all choices may be available on all operating systems.
58# In a Windows environment this must be set to your system time zone.
59TIME_ZONE = 'Europe/London'
60
61# Language code for this installation. All choices can be found here:
62# http://www.i18nguy.com/unicode/language-identifiers.html
63LANGUAGE_CODE = 'en-gb'
64
65SITE_ID = 1
66
67# If you set this to False, Django will make some optimizations so as not
68# to load the internationalization machinery.
69USE_I18N = True
70
71# If you set this to False, Django will not format dates, numbers and
72# calendars according to the current locale.
73USE_L10N = True
74
75# If you set this to False, Django will not use timezone-aware datetimes.
76USE_TZ = True
77
78# Absolute filesystem path to the directory that will hold user-uploaded files.
79# Example: "/home/media/media.lawrence.com/media/"
80MEDIA_ROOT = ''
81
82# URL that handles the media served from MEDIA_ROOT. Make sure to use a
83# trailing slash.
84# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
85MEDIA_URL = ''
86
87# Absolute path to the directory static files should be collected to.
88# Don't put anything in this directory yourself; store your static files
89# in apps' "static/" subdirectories and in STATICFILES_DIRS.
90# Example: "/home/media/media.lawrence.com/static/"
91STATIC_ROOT = '/static'
92
93# URL prefix for static files.
94# Example: "http://media.lawrence.com/static/"
95STATIC_URL = '/static/'
96
97# Additional locations of static files
98STATICFILES_DIRS = (
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# Make this unique, and don't share it with anybody.
113SECRET_KEY = '=+l)#o$ugq4pc14*$08q5gw(&0@nns@gm&2f=bx0_*jc1+y%w1'
114
115# List of callables that know how to import templates from various sources.
116TEMPLATE_LOADERS = (
117    'django.template.loaders.filesystem.Loader',
118    'django.template.loaders.app_directories.Loader',
119#     'django.template.loaders.eggs.Loader',
120)
121
122MIDDLEWARE_CLASSES = (
123    'django.middleware.common.CommonMiddleware',
124    'django.contrib.sessions.middleware.SessionMiddleware',
125    'django.middleware.csrf.CsrfViewMiddleware',
126    'django.contrib.auth.middleware.AuthenticationMiddleware',
127    'django.contrib.messages.middleware.MessageMiddleware',
128    'django_authopenid.middleware.OpenIDMiddleware',
129    'dj_security.middleware.DJS_Middleware',
130    # Uncomment the next line for simple clickjacking protection:
131    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
132)
133
134ROOT_URLCONF = 'dj_security.urls'
135
136# Python dotted path to the WSGI application used by Django's runserver.
137#WSGI_APPLICATION = 'dj_security.wsgi.application'
138
139TEMPLATE_DIRS = (
140    decode_relative_path('static/templates')
141    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
142    # Always use forward slashes, even on Windows.
143    # Don't forget to use absolute paths, not relative paths.
144)
145
146INSTALLED_APPS = (
147    'django.contrib.auth',
148    'django.contrib.contenttypes',
149    'django.contrib.sessions',
150    'django.contrib.sites',
151    'django.contrib.messages',
152    'django.contrib.staticfiles',
153    'registration',
154    'django.contrib.humanize',
155    'django_authopenid',
156    'dj_security',
157    # Uncomment the next line to enable the admin:
158    # 'django.contrib.admin',
159    # Uncomment the next line to enable admin documentation:
160    # 'django.contrib.admindocs',
161)
162
163NOT_ENCODE = ['password', 'backend']
164SHARED_SECRET = 'sharedsecret'   
165APPLICATION_ROOT = 'PROJECT_NAME_PAR/'
166if APPLICATION_ROOT.startswith('PROJECT_NAME_'):
167    APPLICATION_ROOT = ''
168COOKIE_DOMAIN = 'COOKIE_DOMAIN_PAR'
169if COOKIE_DOMAIN.startswith('COOKIE_DOMAIN_'):
170    COOKIE_DOMAIN = 'uk'
171   
172# One-week activation window; you may, of course, use a different value.   
173ACCOUNT_ACTIVATION_DAYS = 7
174
175# Adds to the site framework the current machine
176# where dj_security is deployed
177import socket
178try:
179    HOSTNAME = socket.gethostname()
180except Exception:
181    HOSTNAME = 'localhost'
182from django.contrib.sites.models import Site
183from django.db.utils import DatabaseError   
184try:
185    site = Site()
186    site.name = HOSTNAME
187    site.domain = HOSTNAME + '/' + APPLICATION_ROOT
188    site.save()
189    #Sets the default site
190    SITE_ID = site.pk
191except DatabaseError as ex:
192    print str(ex)
193
194
195
196TEMPLATE_CONTEXT_PROCESSORS = (
197    'django_authopenid.context_processors.authopenid',
198    'django.core.context_processors.i18n',
199)
200
201AUTH_PROFILE_MODULE = 'dj_security.UserProfile'
202
203# A sample logging configuration. The only tangible logging
204# performed by this configuration is to send an email to
205# the site admins on every HTTP 500 error when DEBUG=False.
206# See http://docs.djangoproject.com/en/dev/topics/logging for
207# more details on how to customize your logging configuration.
208LOGGING = {
209    'version': 1,
210    'disable_existing_loggers': False,
211    'formatters': {
212        'verbose': {
213            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
214        },
215        'simple': {
216            'format': '%(levelname)s %(message)s'
217        },
218    },
219    'filters': {
220        'require_debug_false': {
221            '()': 'django.utils.log.RequireDebugFalse'
222        }
223    },
224    'handlers': {
225        'mail_admins': {
226            'level': 'ERROR',
227            'filters': ['require_debug_false'],
228            'class': 'django.utils.log.AdminEmailHandler'
229        },
230        'console':{
231            'level':'DEBUG',
232            'class':'logging.StreamHandler',
233            'formatter': 'verbose'
234        }
235    },
236    'loggers': {
237        'django.request': {
238            'handlers': ['mail_admins'],
239            'level': 'ERROR',
240            'propagate': True,
241        },
242        'dj_security': {
243            'handlers': ['console'],
244            'level': 'DEBUG',
245            'propagate': True,
246        }
247    }
248}
Note: See TracBrowser for help on using the repository browser.