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

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

Does not use HTTPResponseRedirect but a "meta refresh" from the logged_in.html page

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