1 | |
---|
2 | import os, sys, ConfigParser |
---|
3 | |
---|
4 | from socket import gethostbyname_ex |
---|
5 | |
---|
6 | config = ConfigParser.RawConfigParser() |
---|
7 | config.read('/etc/cmt/cmt.conf') |
---|
8 | |
---|
9 | try: |
---|
10 | DATABASE_USER = config.get('database', 'USER') |
---|
11 | DATABASE_PASSWORD = config.get('database', 'PASSWORD') |
---|
12 | DATABASE_HOST = config.get('database', 'HOST') |
---|
13 | DATABASE_ENGINE = config.get('database', 'ENGINE') |
---|
14 | DATABASE_NAME = config.get('database', 'NAME') |
---|
15 | |
---|
16 | except ConfigParser.NoOptionError, details: |
---|
17 | |
---|
18 | print 'Config file error: %s' %str(details) |
---|
19 | sys.exit(1) |
---|
20 | |
---|
21 | try: # Optional |
---|
22 | DATABASE_PORT = config.get('database', 'PORT') |
---|
23 | TEST_DATABASE_NAME = config.get('database', 'TEST_NAME') |
---|
24 | |
---|
25 | except ConfigParser.NoOptionError, details: |
---|
26 | |
---|
27 | #whatever: optional arguments: unset |
---|
28 | try: |
---|
29 | del DATABASE_PORT |
---|
30 | del TEST_DATABASE_NAME |
---|
31 | |
---|
32 | except NameError: |
---|
33 | |
---|
34 | # care more |
---|
35 | pass |
---|
36 | |
---|
37 | try: |
---|
38 | gethostbyname_ex( DATABASE_HOST ) |
---|
39 | except socket.gaierror, details: |
---|
40 | print 'Unable to resolv database host: %s' %DATABASE_HOST |
---|
41 | print 'Exiting.' |
---|
42 | sys.exit(1) |
---|
43 | |
---|
44 | # Documentation of settings can be found on: |
---|
45 | # |
---|
46 | # http://docs.djangoproject.com/en/dev/ref/settings/ |
---|
47 | |
---|
48 | # Only set CLIENT_ONLY to False on the central CMT-server |
---|
49 | CLIENT_ONLY = True |
---|
50 | |
---|
51 | DEBUG = True |
---|
52 | |
---|
53 | ADMINS = ( |
---|
54 | ('Sil Westerveld', 'sil.westerveld@sara.nl'), |
---|
55 | #('Your Name', 'your_email@domain.com'), |
---|
56 | ) |
---|
57 | |
---|
58 | MANAGERS = ADMINS |
---|
59 | |
---|
60 | ##### |
---|
61 | # |
---|
62 | # <AUTH AGAINST LDAP> (based on http://packages.python.org/django-auth-ldap/) |
---|
63 | # |
---|
64 | if not CLIENT_ONLY: |
---|
65 | import ldap |
---|
66 | from django_auth_ldap.config import LDAPSearch, PosixGroupType |
---|
67 | |
---|
68 | |
---|
69 | # Baseline configuration. |
---|
70 | AUTH_LDAP_SERVER_URI = "ldaps://ldap.cua.sara.nl" |
---|
71 | |
---|
72 | # Set AUTH_LDAP_USER_DN_TEMPLATE to a template that will produce the |
---|
73 | # authenticating user's DN directly. This template should have one |
---|
74 | # placeholder, %(user)s. |
---|
75 | AUTH_LDAP_USER_DN_TEMPLATE = 'uid=%(user)s,ou=Users,dc=hpcv,dc=sara,dc=nl' |
---|
76 | |
---|
77 | # Set up the basic group parameters. |
---|
78 | AUTH_LDAP_GROUP_SEARCH = LDAPSearch('ou=Groups,dc=hpcv,dc=sara,dc=nl', |
---|
79 | ldap.SCOPE_SUBTREE, '(objectClass=posixGroup)', |
---|
80 | ) |
---|
81 | AUTH_LDAP_GROUP_TYPE = PosixGroupType() |
---|
82 | |
---|
83 | ## Only users in this group can log in. |
---|
84 | AUTH_LDAP_REQUIRE_GROUP = 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl' |
---|
85 | |
---|
86 | # Populate the Django user from the LDAP directory. |
---|
87 | AUTH_LDAP_USER_ATTR_MAP = { |
---|
88 | 'first_name': 'givenName', |
---|
89 | 'last_name': 'sn', |
---|
90 | 'email': 'mail', |
---|
91 | } |
---|
92 | |
---|
93 | AUTH_LDAP_USER_FLAGS_BY_GROUP = { |
---|
94 | 'is_active': 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl', |
---|
95 | 'is_staff': 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl', |
---|
96 | 'is_superuser': 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl', |
---|
97 | } |
---|
98 | |
---|
99 | # This is the default, but I like to be explicit. |
---|
100 | AUTH_LDAP_ALWAYS_UPDATE_USER = True |
---|
101 | |
---|
102 | # Cache group memberships for an hour to minimize LDAP traffic |
---|
103 | AUTH_LDAP_CACHE_GROUPS = True |
---|
104 | AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600 |
---|
105 | |
---|
106 | # Keep ModelBackend around for per-user permissions and maybe a local |
---|
107 | # superuser. |
---|
108 | AUTHENTICATION_BACKENDS = ( |
---|
109 | 'django_auth_ldap.backend.LDAPBackend', |
---|
110 | 'django.contrib.auth.backends.ModelBackend', |
---|
111 | ) |
---|
112 | # |
---|
113 | # </AUTH AGAINST LDAP> |
---|
114 | # |
---|
115 | ##### |
---|
116 | |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | # Local time zone for this installation. Choices can be found here: |
---|
122 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name |
---|
123 | # although not all choices may be available on all operating systems. |
---|
124 | # If running in a Windows environment this must be set to the same as your |
---|
125 | # system time zone. |
---|
126 | TIME_ZONE = 'Europe/Amsterdam' |
---|
127 | |
---|
128 | # Language code for this installation. All choices can be found here: |
---|
129 | # http://www.i18nguy.com/unicode/language-identifiers.html |
---|
130 | LANGUAGE_CODE = 'en-us' |
---|
131 | |
---|
132 | SITE_ID = 1 |
---|
133 | |
---|
134 | # If you set this to False, Django will make some optimizations so as not |
---|
135 | # to load the internationalization machinery. |
---|
136 | USE_I18N = True |
---|
137 | |
---|
138 | # Absolute path to the directory that holds media. |
---|
139 | # Example: "/home/media/media.lawrence.com/" |
---|
140 | MEDIA_ROOT = '' |
---|
141 | |
---|
142 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a |
---|
143 | # trailing slash if there is a path component (optional in other cases). |
---|
144 | # Examples: "http://media.lawrence.com", "http://example.com/media/" |
---|
145 | MEDIA_URL = '' |
---|
146 | |
---|
147 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a |
---|
148 | # trailing slash. |
---|
149 | # Examples: "http://foo.com/media/", "/media/". |
---|
150 | ADMIN_MEDIA_PREFIX = '/admin_media/' |
---|
151 | |
---|
152 | # Make this unique, and don't share it with anybody. |
---|
153 | SECRET_KEY = 'uygv6wrel4o2%x8s4dk2%i6=dp!2bt32$0ne-%_7&j=ez*u$1b' |
---|
154 | |
---|
155 | # List of callables that know how to import templates from various sources. |
---|
156 | TEMPLATE_LOADERS = ( |
---|
157 | 'django.template.loaders.filesystem.load_template_source', |
---|
158 | 'django.template.loaders.app_directories.load_template_source', |
---|
159 | #'django.template.loaders.eggs.load_template_source', |
---|
160 | ) |
---|
161 | |
---|
162 | MIDDLEWARE_CLASSES = ( |
---|
163 | 'django.middleware.common.CommonMiddleware', |
---|
164 | 'django.contrib.sessions.middleware.SessionMiddleware', |
---|
165 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
---|
166 | 'debug_toolbar.middleware.DebugToolbarMiddleware', |
---|
167 | ) |
---|
168 | |
---|
169 | ROOT_URLCONF = 'sara_cmt.urls' |
---|
170 | |
---|
171 | # Templates for the CMT command line interface. |
---|
172 | # (thus, the templates for our configfiles, etc) |
---|
173 | #TODO: think about a (better) way to make this dynamic: |
---|
174 | #TODO: get this out of the settings.py, since it should be in the client config |
---|
175 | import site |
---|
176 | CMT_TEMPLATES_DIR = '%s/etc/templates' % site.sys.prefix |
---|
177 | |
---|
178 | # Templates for the CMT web-frontend. |
---|
179 | TEMPLATE_DIRS = ( |
---|
180 | # Put strings here, like "/home/html/django_templates" |
---|
181 | # or "C:/www/django/templates". |
---|
182 | # Always use forward slashes, even on Windows. |
---|
183 | # Don't forget to use absolute paths, not relative paths. |
---|
184 | os.path.normpath(os.path.join(os.path.dirname(__file__), 'cluster/templates')), |
---|
185 | CMT_TEMPLATES_DIR, |
---|
186 | ) |
---|
187 | |
---|
188 | FIXTURE_DIRS = ( |
---|
189 | # A fixture is a collection of files that contain serialized contents of |
---|
190 | # the database. (can be used for testing) |
---|
191 | os.path.normpath(os.path.join(os.path.dirname(__file__), 'fixtures')), |
---|
192 | ) |
---|
193 | |
---|
194 | |
---|
195 | INSTALLED_APPS = ( |
---|
196 | 'django.contrib.auth', |
---|
197 | 'django.contrib.contenttypes', |
---|
198 | 'django.contrib.sessions', |
---|
199 | 'django.contrib.admin', |
---|
200 | 'django.contrib.databrowse', |
---|
201 | 'django.contrib.webdesign', |
---|
202 | 'sara_cmt.cluster', |
---|
203 | 'django_extensions', |
---|
204 | 'tagging', |
---|
205 | |
---|
206 | # Only serverside: |
---|
207 | #'debug_toolbar', |
---|
208 | #'south', |
---|
209 | ) |
---|
210 | |
---|
211 | # Append your IP to use the debug_toolbar |
---|
212 | INTERNAL_IPS = ( |
---|
213 | #'145.100.6.163', # saralt0115 |
---|
214 | '127.0.0.1', |
---|
215 | ) |
---|