~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/conf/conf.py

Changed new-style config file to a hierarchical one with nice shiny new names.
Note that this will break the previous revision's config files. Hopefully you
didn't just put IVLE into production off this branch in the past 30 minutes !!

Upgraded both compatibility layers (setup/configure.py and conf.py) to use the
new format (they both now contain a dict mapping the legacy names to the new
path names).

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        return '/etc/ivle/ivle.conf'
47
47
    raise RuntimeError("Could not find IVLE config file")
48
48
 
49
 
conffile = search_conffile()
 
49
try:
 
50
    conffile = search_conffile()
 
51
except RuntimeError, e:
 
52
    raise ImportError(str(e))
 
53
 
50
54
conf = configobj.ConfigObj(conffile)
51
55
 
52
 
CONFIG_OPTIONS = ('root_dir', 'prefix', 'data_path', 'log_path',
53
 
    'public_host', 'allowed_uids', 'db_host', 'db_port', 'db_dbname',
54
 
    'db_forumdbname', 'db_user', 'db_password', 'auth_modules', 'ldap_url',
55
 
    'ldap_format_string', 'subject_pulldown_modules', 'svn_addr',
56
 
    'usrmgt_host', 'usrmgt_port', 'usrmgt_magic', 'forum_secret'
57
 
    )
58
 
 
59
 
for opt in CONFIG_OPTIONS:
60
 
    globals()[opt] = conf[opt]
 
56
# This dict maps legacy config option names to new config option paths
 
57
# ('section/option_name')
 
58
CONFIG_OPTIONS = {
 
59
    'root_dir': 'urls/root',
 
60
    'prefix': 'paths/prefix',
 
61
    'data_path': 'paths/data',
 
62
    'log_path': 'paths/logs',
 
63
    'python_site_packages_override': 'paths/site_packages',
 
64
    'public_host': 'urls/public_host',
 
65
    'allowed_uids': 'os/allowed_uids',
 
66
    'db_host': 'database/host',
 
67
    'db_port': 'database/port',
 
68
    'db_dbname': 'database/name',
 
69
    'db_forumdbname': 'plugins/forum/dbname',
 
70
    'db_user': 'database/username',
 
71
    'db_password': 'database/password',
 
72
    'auth_modules': 'auth/modules',
 
73
    'ldap_url': 'auth/ldap_url',
 
74
    'ldap_format_string': 'auth/ldap_format_string',
 
75
    'subject_pulldown_modules': 'auth/subject_pulldown_modules',
 
76
    'svn_addr': 'urls/svn_addr',
 
77
    'usrmgt_host': 'usrmgt/host',
 
78
    'usrmgt_port': 'usrmgt/port',
 
79
    'usrmgt_magic': 'usrmgt/magic',
 
80
    'forum_secret': 'plugins/forum/secret',
 
81
}
 
82
 
 
83
for legacyopt, newopt_path in CONFIG_OPTIONS.iteritems():
 
84
    # Iterate over each segment of the path, and find the value in conf file
 
85
    try:
 
86
        value = conf
 
87
        for seg in newopt_path.split('/'):
 
88
            value = value[seg]
 
89
        globals()[legacyopt] = value
 
90
    except KeyError:
 
91
        globals()[legacyopt] = None
 
92
 
 
93
# XXX Munge some nice shiny new-style values into horrible old-style values
 
94
# IRONY: These have just been split from commas. We need to re-join it so that
 
95
# pulldown_subj and auth_modules can re-split them.
 
96
subject_pulldown_modules = ','.join(subject_pulldown_modules)
 
97
auth_modules = ','.join(auth_modules)
61
98
 
62
99
# XXX Convert db_port and usrmgt_port to int.
63
100
# Because.
78
115
 
79
116
# 'site-packages' directory in Python, where Python libraries are to be
80
117
# installed.
81
 
PYTHON_VERSION = sys.version[0:3]   # eg. "2.5"
82
 
python_site_packages = os.path.join(prefix,
83
 
                           'lib/python%s/site-packages' % PYTHON_VERSION)
 
118
if python_site_packages_override is None:
 
119
    PYTHON_VERSION = sys.version[0:3]   # eg. "2.5"
 
120
    python_site_packages = os.path.join(prefix,
 
121
                               'lib/python%s/site-packages' % PYTHON_VERSION)
 
122
else:
 
123
    python_site_packages = python_site_packages_override
84
124
 
85
125
# In the local file system, where the student/user jails will be mounted.
86
126
# Only a single copy of the jail's system components will be stored here -