[Mpuls-commits] r4040 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 27 09:59:28 CEST 2010


Author: torsten
Date: 2010-10-27 09:59:28 +0200 (Wed, 27 Oct 2010)
New Revision: 4040

Modified:
   base/trunk/mpulsweb/lib/security.py
Log:
* mpulsweb/lib/security.py (get_dbname_from_list): Simplified.
After moving logic into the auth controller this method just returns
the saved db name in the session var "DB_NAME_FROM_LIST".


Modified: base/trunk/mpulsweb/lib/security.py
===================================================================
--- base/trunk/mpulsweb/lib/security.py	2010-10-27 07:57:22 UTC (rev 4039)
+++ base/trunk/mpulsweb/lib/security.py	2010-10-27 07:59:28 UTC (rev 4040)
@@ -44,7 +44,7 @@
 
 from webob.exc import HTTPUnauthorized
 
-from pylons import request, config, g, h
+from pylons import request, config, g
 
 from mpulsweb.lib.db import DB, db, enter, leave
 
@@ -233,32 +233,20 @@
     """
     return config.get('mpuls.db.name')
 
-def get_dbname_from_formparam():
-    """Return the name of the database name from the submitted
-    "DB_NAME_FROM_LIST" param on the login page. Further submitted dbname must
-    be defined in the dblist json file.
-    """
-    dbname = request.params.get('DB_NAME_FROM_LIST') or session.get('DB_NAME_FROM_LIST')
-    if dbname:
-        # Check if the name is part of the db list
-        dblist = h.get_db_selectionlist()
-        if dbname in dblist.keys():
-            session['DB_NAME_FROM_LIST'] = dbname
-            session.save()
-            return dbname 
-        return None
-    else:
-        return None
+def get_dbname_from_list():
+    """Return the name of the database name from the saved db name in the
+    session. The session var gets set in the login-method of the auth controller."""
+    return session.get('DB_NAME_FROM_LIST')
 
-
 def getDbName():
-    """Return the KA-specific part of the database name.
-    The value is taken from HTTP-Headers containing information from the
-    SSL-client-certificate using get_dbname_from_http_header().  If
-    those headers are not set, the value is taken from the configuration
-    using get_dbname_from_config().
+    """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
+    from the SSL-client-certificate using get_dbname_from_http_header().  If
+    those headers are not set, the value is taken from the configuration using
+    get_dbname_from_config().
     """
-    dbname = get_dbname_from_formparam()
+    dbname = get_dbname_from_list()
     if not dbname:
         log.info("Could not determine database name from Request params,"
                  " falling back to HTTP header ")



More information about the Mpuls-commits mailing list