[Mpuls-commits] r780 - in waska/trunk: . waskaweb/i18n/de/LC_MESSAGES waskaweb/lib waskaweb/public/images waskaweb/templates

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 20 10:49:38 CET 2010


Author: frank
Date: 2010-01-20 10:49:36 +0100 (Wed, 20 Jan 2010)
New Revision: 780

Added:
   waska/trunk/waskaweb/public/images/weblogo_waska.png
   waska/trunk/waskaweb/templates/login-list.mako
Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
   waska/trunk/waskaweb/lib/app_globals.py
   waska/trunk/waskaweb/lib/helpers.py
   waska/trunk/waskaweb/lib/security.py
Log:
Added optional choice list to login page to select database (in setups
	without client certificates)


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2010-01-19 20:28:59 UTC (rev 779)
+++ waska/trunk/ChangeLog.txt	2010-01-20 09:49:36 UTC (rev 780)
@@ -1,3 +1,27 @@
+2010-01-20 	Frank Koormann <frank.koormann at intevation.de>
+
+	Added optional choice list to login page to select database (in setups
+	without client certificates)
+
+	* waskaweb/i18n/de/LC_MESSAGES/waskaweb.po: 
+	New translations for choice list login page.
+	
+	* waskaweb/lib/helpers.py (load_db_list_from_file): New, load db list.
+	(getDbSelectionList): Helper function called from mako templates.
+
+	* waskaweb/lib/security.py (getDbName): Enhanced version: DB Name is 
+	either (in this order) read from environment variable SSL_CLIENT_S_DN_CN,
+	parameter DB_NAME_FROM_LIST and stored in session or session.
+
+	* waskaweb/lib/app_globals.py: Read db list if configured by 
+	parameter 'db_list_file'.
+
+	* waskaweb/templates/login-list.mako: New, to be copied to login.mako 
+	in setups when needed.
+
+	* waskaweb/public/images/weblogo_waska.png: New mpuls WASKA web Logo,
+	to be copied to logo_ka_75.png in setups when needed.
+
 2010-01-13 	Torsten Irlaender  <torsten.irlaender at intevation.de>
 
 	Issue903:

Modified: waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
===================================================================
--- waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po	2010-01-19 20:28:59 UTC (rev 779)
+++ waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po	2010-01-20 09:49:36 UTC (rev 780)
@@ -451,6 +451,14 @@
 msgstr "Anmeldekennung und/oder Passwort sind nicht korrekt"
 
 #: waskaweb/templates/login.mako:16
+msgid "login_select_project"
+msgstr "Wählen Sie bitte ein Projekt aus."
+
+#: waskaweb/templates/login.mako:16
+msgid "login_label_project"
+msgstr "Projekt:"
+
+#: waskaweb/templates/login.mako:16
 msgid "login_p_insert_pw_and_identifier"
 msgstr "Geben Sie bitte Anmeldekennung und Passwort ein, um sich anzumelden."
 

Modified: waska/trunk/waskaweb/lib/app_globals.py
===================================================================
--- waska/trunk/waskaweb/lib/app_globals.py	2010-01-19 20:28:59 UTC (rev 779)
+++ waska/trunk/waskaweb/lib/app_globals.py	2010-01-20 09:49:36 UTC (rev 780)
@@ -30,6 +30,7 @@
 from waskaweb.lib.formular_help import HelpProvider 
 
 import waskaweb.lib.security    as security
+from  waskaweb.lib.helpers import load_db_list_from_file,DBS_LIST
 
 from waskaweb.lib.timelog import setupTimeLogging
 from waskaweb.lib.config import MpulsConfig, get_path
@@ -115,3 +116,9 @@
         if mapping_file:
             security.load_db_mapping_from_file(mapping_file)
 
+        # File to define section list (instead of reading from client cert)
+        list_file = config.get('db_list_file')
+
+        if list_file:
+            load_db_list_from_file(list_file)
+

Modified: waska/trunk/waskaweb/lib/helpers.py
===================================================================
--- waska/trunk/waskaweb/lib/helpers.py	2010-01-19 20:28:59 UTC (rev 779)
+++ waska/trunk/waskaweb/lib/helpers.py	2010-01-20 09:49:36 UTC (rev 780)
@@ -30,6 +30,7 @@
 import locale
 import sys
 import re
+import os.path
 from pylons import c, cache, config, g, request, response, session
 from webhelpers import *
 from waskaweb.lib.adelexml import EVAL_NAMES, EVAL_DESCRIPTIONS
@@ -41,6 +42,29 @@
 VALID_DATE = re.compile(r'^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$')
 VALID_TIME = re.compile(r'^([0-9]{1,2}):([0-9]{2})')
 
+DBS_LIST = {}
+
+def load_db_list_from_file(fname):
+    if os.path.isfile(fname):
+        global DBS_LIST
+        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:
+                    DBS_LIST[parts[0]] = parts[1]
+        finally:
+            if f:
+                try: f.close()
+                except StandardError, e: 
+                    print e 
+    else:
+        print "No list file found named: %s" % fname
+
+
 def get_adele_name(id=None):
     return EVAL_NAMES.get(str(id), 'Auswertung Nr: %s' % id) 
 
@@ -246,6 +270,10 @@
         print >> sys.stderr, "Could not fetch KA-name from client certificate"
     return ''
 
+def getDbSelectionList():
+    global DBS_LIST
+    return DBS_LIST
+
 def format_date(dt):
     return date2str(dt)
 

Modified: waska/trunk/waskaweb/lib/security.py
===================================================================
--- waska/trunk/waskaweb/lib/security.py	2010-01-19 20:28:59 UTC (rev 779)
+++ waska/trunk/waskaweb/lib/security.py	2010-01-20 09:49:36 UTC (rev 780)
@@ -200,12 +200,31 @@
         print "No file mapping file found named: %s" % fname
 
 def getDbName():
+    """Determine database base name.
+
+        Name is either (in this priority) read from
+        - environment variable SSL_CLIENT_S_DN_CN
+        - parameter DB_NAME_FROM_LIST and stored in session
+        - session
+    """
+ 
     dbname = None
-    try:
-        dbname = request.environ['SSL_CLIENT_S_DN_CN'].split(' ')[3].lower()
-        return NEW_DBS.get(dbname, dbname)
-    except:
-        print >> sys.stderr, "Could not fetch database name from client certificate"
+    if request.environ.has_key('SSL_CLIENT_S_DN_CN'):
+        try:
+            dbname = request.environ['SSL_CLIENT_S_DN_CN'].split(' ')[3].lower()
+            return NEW_DBS.get(dbname, dbname)
+        except: 
+            print >> sys.stderr, "Could not determine database name from client
+certificate."
+    elif request.params.has_key('DB_NAME_FROM_LIST'):
+        dbname = request.params['DB_NAME_FROM_LIST'].lower()
+        session['DB_NAME'] = dbname
+        session.save()
+        return dbname
+    elif session.has_key('DB_NAME'):
+        return session['DB_NAME']
+    else:
+        print >> sys.stderr, "Could not determine database name"
     return dbname 
 
 def checkRole(role):

Added: waska/trunk/waskaweb/public/images/weblogo_waska.png
===================================================================
(Binary files differ)


Property changes on: waska/trunk/waskaweb/public/images/weblogo_waska.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: waska/trunk/waskaweb/templates/login-list.mako
===================================================================
--- waska/trunk/waskaweb/templates/login-list.mako	2010-01-19 20:28:59 UTC (rev 779)
+++ waska/trunk/waskaweb/templates/login-list.mako	2010-01-20 09:49:36 UTC (rev 780)
@@ -0,0 +1,51 @@
+## -*- coding: utf-8 -*-
+<%! import waskaweb.lib.filters as F %>
+<%inherit file="main_login.mako" />
+<h1>${_('login_header_waska_login')}</h1>
+<div id="waska_form_login">
+
+% if c.login_failed:
+  <div class="form_errors">
+    <a name="error_list"><h1>${_('login_input_error')}</h1></a>
+    <ul>
+      <li>${_('login_input_error_message')}</li>
+    </ul>
+  </div>
+% endif
+
+##<p><strong>Kompetenzagentur: ${F.H(h.getKAName())}</strong><br>${_('login_p_insert_pw_and_identifier')}</p>
+<form name="login" action="${h.url_for(controller='waska', action='loginAction')}" accept-charset="UTF-8" method="POST">
+<p>${_('login_select_project')}
+<div class="label">
+   <label for="project">${_('login_label_project')}</label>
+</div>
+<select name='DB_NAME_FROM_LIST' size=1>
+    % for k, v in h.getDbSelectionList().iteritems():
+         <option value="${k}">${v}</option>
+    % endfor
+</select></p>
+
+<p>${_('login_p_insert_pw_and_identifier')}
+<div class="label">
+   <label for="login">${_('login_label_identifier')}</label>
+   
+</div>
+<div class="input">
+   <input type="text" size="20" name="username" maxlength="64">
+</div>
+<div class="clearer"> </div>
+<div class="label">
+    <label for="pass">${_('login_label_pw')}</label>
+    
+</div>
+
+<div class="input">
+    <input type="password" size="20" name="password">
+  </div>
+</p>
+<div class="clearer"> </div>
+<p id="login_btn">
+<input type="submit" value="Anmelden" name="authform">
+</p>
+</form>
+</div>



More information about the Mpuls-commits mailing list