[Mpuls-commits] r890 - wasko/branches/2.0/waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 26 15:13:18 CET 2010


Author: torsten
Date: 2010-01-26 15:13:18 +0100 (Tue, 26 Jan 2010)
New Revision: 890

Modified:
   wasko/branches/2.0/waskaweb/lib/security.py
Log:
* waskaweb/lib/security.py (hasRole): New. Copied from lib.helpers



Modified: wasko/branches/2.0/waskaweb/lib/security.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/security.py	2010-01-26 14:11:40 UTC (rev 889)
+++ wasko/branches/2.0/waskaweb/lib/security.py	2010-01-26 14:13:18 UTC (rev 890)
@@ -233,4 +233,23 @@
 
     return decorator(validate)
 
+def hasRole(rolelist):
+    old_role_names = {
+        'cm_ka': 'cm',
+        'admin_ka': 'admin',
+        'pb_ka': 'pb',
+        }
+    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.
+            conv_roles.append(old_role_names.get(r, r))
+        user_role = user.getPermissionRole()
+        return user_role in conv_roles
+    except KeyError:
+        return False
+
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list