[Mpuls-commits] r4252 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 23 16:40:51 CET 2010


Author: bh
Date: 2010-11-23 16:40:50 +0100 (Tue, 23 Nov 2010)
New Revision: 4252

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/security.py
Log:
Fix mpuls/issue1462

* mpulsweb/lib/security.py (get_unmapped_db_name, getDbName):
Rename getDbName to get_unmapped_db_name and introduce a new
getDbName which applies the db mapping to the dbname.
(get_db_parameters, checkLogin): Use get_unmapped_db_name instead
of getDbName because we actually need the unmapped name here.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-11-23 15:36:55 UTC (rev 4251)
+++ base/trunk/ChangeLog	2010-11-23 15:40:50 UTC (rev 4252)
@@ -1,5 +1,15 @@
 2010-11-23  Bernhard Herzog  <bh at intevation.de>
 
+	Fix mpuls/issue1462
+
+	* mpulsweb/lib/security.py (get_unmapped_db_name, getDbName):
+	Rename getDbName to get_unmapped_db_name and introduce a new
+	getDbName which applies the db mapping to the dbname.
+	(get_db_parameters, checkLogin): Use get_unmapped_db_name instead
+	of getDbName because we actually need the unmapped name here.
+
+2010-11-23  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/security.py (get_db_parameters): Remove the first
 	parameter, dbagency.  It's always the unmapped db name currently
 	still returned by getDbName() anyway, so use that automatically

Modified: base/trunk/mpulsweb/lib/security.py
===================================================================
--- base/trunk/mpulsweb/lib/security.py	2010-11-23 15:36:55 UTC (rev 4251)
+++ base/trunk/mpulsweb/lib/security.py	2010-11-23 15:40:50 UTC (rev 4252)
@@ -91,7 +91,7 @@
     return True
 
 def checkLogin(user, password):
-    dbname = getDbName()
+    dbname = get_unmapped_db_name()
     if (not password or not validPassword(password)
         or not dbname or not check_re.match(dbname)
         or not check_re.match(user)):
@@ -238,7 +238,7 @@
     session. The session var gets set in the login-method of the auth controller."""
     return session.get('DB_NAME_FROM_LIST')
 
-def getDbName():
+def get_unmapped_db_name():
     """Return the KA-specific part of the database name. In first place it
     tries to get the name from a saved db name in a session var.  If this ther
     is no value the value is taken from HTTP-Headers containing information
@@ -263,7 +263,12 @@
 
     return dbname
 
+def getDbName():
+    """Like get_unmapped_db_name, but apply the dbmapping to the name"""
+    dbname = get_unmapped_db_name()
+    return g.mpuls_dbmapping.get_mapping().get(dbname).get("dbagency", dbname)
 
+
 def get_kaname_from_http_header():
     """Return the KA-name given by HTTP-Header fields.
 
@@ -342,7 +347,7 @@
     user and password.  It can be used directly as a dictionary for the
     keyword parameter of a DB-API connect() call.
     """
-    dbagency = getDbName()
+    dbagency = get_unmapped_db_name()
     mapping = g.mpuls_dbmapping.get_mapping()
     mapped_parameters = mapping.get(dbagency)
     if mapped_parameters:



More information about the Mpuls-commits mailing list