bd1474bdc84e678f76f37c2fbeda472add2c5e7f
[unfold.git] / myslice / settings.py
1 # Django settings for unfold project.
2
3 import os.path
4
5 import djcelery
6 djcelery.setup_loader()
7
8 ### detect if we're in a build environment
9 try:
10     import manifold
11     building=False
12 except:
13     building=True
14
15 DEBUG = True
16 TEMPLATE_DEBUG = DEBUG
17
18 # compute ROOT from where this file is installed
19 # should fit every need including developers
20 # but you can redefine ROOT if that's not working for you
21 try:
22     # get the directory where this file is
23     ROOT=os.path.dirname(__file__) or '.'
24     # move one step up
25     ROOT=os.path.realpath(ROOT+'/..')
26 except:
27     # something is badly wrong here
28     ROOT=None
29     import traceback
30     traceback.print_exc()
31
32 #### this is where the problem lies I believe
33 # first try to run manage.py collectstatic without this
34 # themes
35 theme=None
36 try:
37     from myslice.configengine import ConfigEngine
38     configEngine = ConfigEngine()
39     if configEngine.myslice.theme :
40         theme = configEngine.myslice.theme
41 except:
42     pass
43     
44 # find out HTTPROOT, which is different from ROOT 
45 # when deployed from a package
46 # this code is run by collectstatic too, so we cannot
47 # assume we have ./static present already
48 HTTPROOT="/var/myslice-f4f"
49 # the place to store local data, like e.g. the sqlite db
50 DATAROOT="/var/unfold"
51 # if not there, then we assume it's from a devel tree
52 if not os.path.isdir (os.path.join(HTTPROOT,"static")):
53     HTTPROOT=ROOT
54
55 if not os.path.isdir(ROOT): raise Exception,"Cannot find ROOT %s for unfold"%ROOT
56 if not os.path.isdir(HTTPROOT): raise Exception,"Cannot find HTTPROOT %s for unfold"%HTTPROOT
57
58 # dec 2013 - we currently have 2 auxiliary subdirs with various utilities
59 # that we do not wish to package 
60 # * sandbox is for plugin developers
61 # * sample is for various test views
62 # for each of these, if we find a directory of that name under ROOT, it then gets
63 # inserted in INSTALLED_APPS and its urls get included (see urls.py)
64 auxiliaries = [ 'sandbox', 'sample', ]
65
66 ####################
67 ADMINS = (
68     # ('your_name', 'your_email@test.com'),
69 )
70
71 MANAGERS = ADMINS
72
73 # Mail configuration
74 #DEFAULT_FROM_EMAIL = "root@theseus.ipv6.lip6.fr"
75 #EMAIL_HOST_PASSWORD = "mypassword"
76
77 EMAIL_HOST = "localhost"
78 EMAIL_PORT = 25
79 EMAIL_USE_TLS = False
80
81 # use the email for debugging purpose
82 # turn on debugging: 
83 # python -m smtpd -n -c DebuggingServer localhost:1025
84
85 #if DEBUG:
86 #    EMAIL_HOST = 'localhost'
87 #    EMAIL_PORT = 1025
88 #    EMAIL_HOST_USER = ''
89 #    EMAIL_HOST_PASSWORD = ''
90 #    EMAIL_USE_TLS = False
91 #    DEFAULT_FROM_EMAIL = 'testing@example.com'
92
93 DATABASES = {
94     'default': {
95         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
96         'NAME': os.path.join(DATAROOT,'unfold.sqlite3'), # Or path to database file if using sqlite3.
97         'USER': '',                      # Not used with sqlite3.
98         'PASSWORD': '',                  # Not used with sqlite3.
99         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
100         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
101     }
102 }
103
104 # Local time zone for this installation. Choices can be found here:
105 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
106 # although not all choices may be available on all operating systems.
107 # In a Windows environment this must be set to your system time zone.
108 TIME_ZONE = 'Europe/Paris'
109
110 # Language code for this installation. All choices can be found here:
111 # http://www.i18nguy.com/unicode/language-identifiers.html
112 LANGUAGE_CODE = 'en-us'
113
114 SITE_ID = 1
115
116 # If you set this to False, Django will make some optimizations so as not
117 # to load the internationalization machinery.
118 USE_I18N = True
119
120 # If you set this to False, Django will not format dates, numbers and
121 # calendars according to the current locale.
122 USE_L10N = True
123
124 # If you set this to False, Django will not use timezone-aware datetimes.
125 USE_TZ = True
126
127 # Absolute filesystem path to the directory that will hold user-uploaded files.
128 # Example: "/home/media/media.lawrence.com/media/"
129 MEDIA_ROOT = ''
130
131 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
132 # trailing slash.
133 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
134 MEDIA_URL = ''
135
136 # Absolute path to the directory static files should be collected to.
137 # Don't put anything in this directory yourself; store your static files
138 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
139 # Example: "/home/media/media.lawrence.com/static/"
140 STATIC_ROOT = os.path.join(HTTPROOT,'static')
141
142 # URL prefix for static files.
143 # Example: "http://media.lawrence.com/static/"
144 STATIC_URL = '/static/'
145
146 # Additional locations of static files
147 STATICFILES_DIRS = (
148     # Put strings here, like "/home/html/static" or "C:/www/django/static".
149     # Always use forward slashes, even on Windows.
150     # Don't forget to use absolute paths, not relative paths.
151     # Thierry : we do not need to detail the contents 
152     # of our 'apps' since they're mentioned in INSTALLED_APPS
153 )
154
155 # Needed by PluginFinder
156 PLUGIN_DIR = os.path.join(ROOT,'plugins')
157 # ThirdPartyFinder
158 THIRDPARTY_DIR = os.path.join(ROOT, 'third-party')
159
160 # List of finder classes that know how to find static files in
161 # various locations.
162 STATICFILES_FINDERS = (
163 # Thierry : no need for this one    
164 #    'django.contrib.staticfiles.finders.FileSystemFinder',
165     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
166     'unfold.collectstatic.PluginFinder',
167     'unfold.collectstatic.ThirdPartyFinder',
168 ###    'django.contrib.staticfiles.finders.DefaultStorageFinder',
169 )
170
171 #TEMPLATE_CONTEXT_PROCESSORS = (
172 #    'django.contrib.auth.context_processors.auth',
173 #    'django.core.context_processors.debug',
174 #    'django.core.context_processors.i18n',
175 #    'django.core.context_processors.media',
176 #    'django.core.context_processors.static',
177 #    'django.core.context_processors.request',
178 #    'django.contrib.messages.context_processors.messages',
179 #)
180
181 # Make this unique, and don't share it with anybody.
182 SECRET_KEY = 't%n(3h)&r^n8(+8)(sp29t^$c2#t(m3)e2!02l8w1#36tl#t27'
183
184 # List of callables that know how to import templates from various sources.
185 TEMPLATE_LOADERS = (
186     'django.template.loaders.filesystem.Loader',
187     'django.template.loaders.app_directories.Loader',
188 #     'django.template.loaders.eggs.Loader',
189 )
190
191 MIDDLEWARE_CLASSES = (
192     'django.middleware.common.CommonMiddleware',
193     'django.contrib.sessions.middleware.SessionMiddleware',
194     'django.middleware.csrf.CsrfViewMiddleware',
195     'django.contrib.auth.middleware.AuthenticationMiddleware',
196     'django.contrib.messages.middleware.MessageMiddleware',
197     # Uncomment the next line for simple clickjacking protection:
198     # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
199 )
200
201 ROOT_URLCONF = 'myslice.urls'
202
203 # Python dotted path to the WSGI application used by Django's runserver.
204 WSGI_APPLICATION = 'unfold.wsgi.application'
205
206 TEMPLATE_DIRS = [ ]
207 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
208 # Always use forward slashes, even on Windows.
209 # Don't forget to use absolute paths, not relative paths.
210 if theme is not None:
211     TEMPLATE_DIRS.append ( os.path.join(HTTPROOT,"portal/templates", theme))
212 TEMPLATE_DIRS.append     ( os.path.join(HTTPROOT,"portal/templates"))
213 TEMPLATE_DIRS.append     (  os.path.join(HTTPROOT,"templates"))
214
215 INSTALLED_APPS = [ 
216     'django.contrib.auth',
217     'django.contrib.contenttypes',
218     'django.contrib.sessions',
219     'django.contrib.sites',
220     'django.contrib.messages',
221     'django.contrib.staticfiles',
222     # handling the {% insert %} and {% container %} tags
223     # see details in devel/django-insert-above-1.0-4
224     'insert_above',
225     # our django project
226     'myslice',
227     # the core of the UI
228     'auth', 
229     'manifoldapi',
230     'unfold',
231     # plugins
232     'plugins',
233     # views - more or less stable 
234     'ui',
235     # managing database migrations
236     'south', 
237     # Uncomment the next line to enable the admin:
238      'django.contrib.admin',
239         # FORGE Plugin app
240         'djcelery',
241         'forge',
242     # Uncomment the next line to enable admin documentation:
243     # 'django.contrib.admindocs',
244     'portal',
245     # SLA
246     'sla',
247 ]
248 # this app won't load in a build environment
249 if not building: INSTALLED_APPS.append ('rest')
250
251 BROKER_URL = "amqp://myslice:myslice@localhost:5672/myslice"
252
253 for aux in auxiliaries:
254     if os.path.isdir(os.path.join(ROOT,aux)): 
255         print "Using devel auxiliary",aux
256         INSTALLED_APPS.append(aux)
257
258 ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
259
260 # A sample logging configuration. The only tangible logging
261 # performed by this configuration is to send an email to
262 # the site admins on every HTTP 500 error when DEBUG=False.
263 # See http://docs.djangoproject.com/en/dev/topics/logging for
264 # more details on how to customize your logging configuration.
265 LOGGING = {
266     'version': 1,
267     'disable_existing_loggers': False,
268     'filters': {
269         'require_debug_false': {
270             '()': 'django.utils.log.RequireDebugFalse'
271         }
272     },
273     'handlers': {
274         'mail_admins': {
275             'level': 'ERROR',
276             'filters': ['require_debug_false'],
277             'class': 'django.utils.log.AdminEmailHandler',
278         }
279     },
280     'loggers': {
281         'django.request': {
282             'handlers': ['mail_admins'],
283             'level': 'ERROR',
284             'propagate': True,
285         },
286     }
287 }
288
289 AUTHENTICATION_BACKENDS = ('auth.manifoldbackend.ManifoldBackend',
290                            'django.contrib.auth.backends.ModelBackend')
291
292 ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests
293 # without this setting django will return a 403 forbidden error, which is fine
294 # if you need to see the error message then use this setting
295 CSRF_FAILURE_VIEW = 'manifoldapi.manifoldproxy.csrf_failure'
296
297 #################### for insert_above
298 #IA_JS_FORMAT = "<script type='text/javascript' src='{URL}' />"
299 # put stuff under static/
300 # IA_MEDIA_PREFIX = '/code/'
301
302 ####SLA#####
303
304 SLA_MANAGER_URL = "http://157.193.215.125:4001/sla-collector/sla"
305 #SLA_MANAGER_URL = "http://172.24.76.28:8000/sla"
306 SLA_MANAGER_USER = "portal"
307 SLA_MANAGER_PASSWORD = "password"