[Mpuls-commits] r220 - in waska/trunk: . waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Nov 14 12:45:17 CET 2008
Author: teichmann
Date: 2008-11-14 12:45:17 +0100 (Fri, 14 Nov 2008)
New Revision: 220
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/lib/app_globals.py
waska/trunk/waskaweb/lib/security.py
Log:
Added method to load a database remapping from file.
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2008-11-12 11:37:26 UTC (rev 219)
+++ waska/trunk/ChangeLog.txt 2008-11-14 11:45:17 UTC (rev 220)
@@ -1,3 +1,12 @@
+2008-11-14 Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
+ * waskaweb/lib/app_globals.py: looking for a 'db_mapping_file' entry
+ in config. If found try to load db name remapping. Format:
+ # comment
+ new-name;old-name
+
+ * waskaweb/lib/security.py: added function to load mapping from file.
+
2008-11-03 Sascha L. Teichmann <sascha.teichmann at intevation.de>
Commented out evaluation of ESF Stammblatt.
Modified: waska/trunk/waskaweb/lib/app_globals.py
===================================================================
--- waska/trunk/waskaweb/lib/app_globals.py 2008-11-12 11:37:26 UTC (rev 219)
+++ waska/trunk/waskaweb/lib/app_globals.py 2008-11-14 11:45:17 UTC (rev 220)
@@ -96,3 +96,9 @@
elif time_host:
setupTimeLogging(int(time_host))
+ # File to remap database name
+ mapping_file = config.get('db_mapping_file')
+
+ if mapping_file:
+ security.load_db_mapping_from_file(mapping_file)
+
Modified: waska/trunk/waskaweb/lib/security.py
===================================================================
--- waska/trunk/waskaweb/lib/security.py 2008-11-12 11:37:26 UTC (rev 219)
+++ waska/trunk/waskaweb/lib/security.py 2008-11-14 11:45:17 UTC (rev 220)
@@ -54,6 +54,9 @@
DBNAME = u'ka_%s_db'
USER = u'ka_%s_%s'
+# maps new FKZs to old
+NEW_DBS = {}
+
check_re = re.compile(r"^[a-z_0-9]+$")
ROLE_SQL = """select groname from pg_group where getOID() = ANY (grolist)"""
ROLE_SQL = """select where getOID() = ANY (grolist)"""
@@ -176,11 +179,28 @@
env = request.environ
return "%s" % env.get('HTTP_USER_AGENT', '')
+def load_db_mapping_from_file(fname):
+ if os.path.isfile(fname):
+ global NEW_DBS
+ f = None
+ try:
+ f = open(fname, "r")
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith("#"): continue
+ parts = line.split(';')
+ if len(parts) > 1:
+ NEW_DBS[parts[0]] = parts[1]
+ finally:
+ if f:
+ try: f.close()
+ except: pass
+
def getDbName():
dbname = None
try:
dbname = request.environ['SSL_CLIENT_S_DN_CN'].split(' ')[3].lower()
- return dbname
+ return NEW_DBS.get(dbname, dbname)
except:
print >> sys.stderr, "Could not fetch database name from client certificate"
return dbname
More information about the Mpuls-commits
mailing list