-
Notifications
You must be signed in to change notification settings - Fork 11
/
settings.py
36 lines (28 loc) · 995 Bytes
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Settings for Norc, including all Django configuration.
Defaults are stored in defaults.py, and local environments are stored in
settings_local.py to avoid version control. This file merely pulls in
settings from those other files.
"""
import os
import sys
try:
import norc
except ImportError, e:
print 'ImportError:', e
sys.exit(1)
from norc.settings_local import *
from norc.defaults import Envs
# Find the user's environment.
env_str = os.environ.get('NORC_ENVIRONMENT')
if not env_str:
raise Exception('You must set the NORC_ENVIRONMENT shell variable.')
try:
cur_env = Envs.ALL[env_str]
except KeyError, ke:
raise Exception("Unknown NORC_ENVIRONMENT '%s'." % env_str)
# Use the settings from that environment.
for s in dir(cur_env):
# If the setting name is a valid constant, add it to globals.
VALID_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'
if not s.startswith('_') and all(map(lambda c: c in VALID_CHARS, s)):
globals()[s] = cur_env[s]