diff options
author | Simo Sorce <simo@redhat.com> | 2013-12-19 23:32:47 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2014-01-23 18:52:51 -0500 |
commit | cd5fc1d17b16ac41c589130ccb0436d74d06a847 (patch) | |
tree | b1caa494ae933d8b5c2aa9fa7f221d31485a294b /src/util/data.py | |
parent | ee0d1ce71d1f4883aecc426595ac86322a91260e (diff) | |
download | ipsilon-cd5fc1d17b16ac41c589130ccb0436d74d06a847.tar.gz ipsilon-cd5fc1d17b16ac41c589130ccb0436d74d06a847.tar.xz ipsilon-cd5fc1d17b16ac41c589130ccb0436d74d06a847.zip |
Add infrastructure to handle login manager plugins
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/util/data.py')
-rwxr-xr-x | src/util/data.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/util/data.py b/src/util/data.py index ec64588..c716ecf 100755 --- a/src/util/data.py +++ b/src/util/data.py @@ -110,3 +110,58 @@ class Store(object): path = os.path.join(self._path, 'userprefs.sqlite') return self._load_user_prefs(path, user) + + def _load_login_config(self, dbname): + con = None + rows = [] + try: + con = sqlite3.connect(dbname) + cur = con.cursor() + cur.executescript(""" + CREATE TABLE IF NOT EXISTS login_config(name TEXT, + option TEXT, + value TEXT) + """) + cur.execute("SELECT * FROM login_config") + rows = cur.fetchall() + con.commit() + except sqlite3.Error, e: + if con: + con.rollback() + cherrypy.log.error("Failed to load config: [%s]" % e) + finally: + if con: + con.close() + + lpo = [] + plco = dict() + for row in rows: + if row[0] == 'global': + if row[1] == 'order': + lpo = row[2].split(',') + continue + if row[0] not in plco: + # one dict per provider + plco[row[0]] = dict() + + conf = plco[row[0]] + if row[1] in conf: + if conf[row[1]] is list: + conf[row[1]].append(row[2]) + else: + v = conf[row[1]] + conf[row[1]] = [v, row[2]] + else: + conf[row[1]] = row[2] + + return (lpo, plco); + + def get_login_config(self): + path = None + if 'admin.config.db' in cherrypy.config: + path = cherrypy.config['admin.config.db'] + if not path: + path = os.path.join(self._path, 'adminconfig.sqlite') + + return self._load_login_config(path) + |