[Mpuls-commits] r778 - in wasko/branches/2.0: . waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 19 21:24:58 CET 2010


Author: bh
Date: 2010-01-19 21:24:58 +0100 (Tue, 19 Jan 2010)
New Revision: 778

Modified:
   wasko/branches/2.0/ChangeLog.txt
   wasko/branches/2.0/waskaweb/lib/helpers.py
Log:
* waskaweb/lib/helpers.py (hasRole): Use a dictionary to map old
role-names to the names.


Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt	2010-01-19 20:20:11 UTC (rev 777)
+++ wasko/branches/2.0/ChangeLog.txt	2010-01-19 20:24:58 UTC (rev 778)
@@ -1,5 +1,10 @@
 2010-01-19  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/lib/helpers.py (hasRole): Use a dictionary to map old
+	role-names to the names.
+
+2010-01-19  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/lib/helpers.py: Fix formatting
 
 2010-01-19  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/waskaweb/lib/helpers.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/helpers.py	2010-01-19 20:20:11 UTC (rev 777)
+++ wasko/branches/2.0/waskaweb/lib/helpers.py	2010-01-19 20:24:58 UTC (rev 778)
@@ -63,17 +63,22 @@
     return tree.render(tree.root, FileCache(), error_pages)
 
 
+# map old role names to the newer non-application-specific names
+_old_role_names = {
+    'cm_ka': 'cm',
+    'admin_ka': 'admin',
+    'pb_ka': 'pb',
+    }
+
 def hasRole(rolelist):
+    # TODO: move to separate security library
     try:
         user = session['USER_AUTHORIZED']
         conv_roles = []
         for r in rolelist:
             # Mapping of rolenames. The old rolenames are used all over the
             # application. So change them here.
-            if   r == 'cm_ka': conv_roles.append('cm')
-            elif r == 'admin_ka': conv_roles.append('admin')
-            elif r == 'pb_ka': conv_roles.append('pb')
-            else: conv_roles.append(r)
+            conv_roles.append(_old_role_names.get(r, r))
         user_role = user.getPermissionRole()
         return user_role in conv_roles
     except KeyError:



More information about the Mpuls-commits mailing list