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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 19 16:57:28 CEST 2011


Author: torsten
Date: 2011-09-19 16:57:27 +0200 (Mon, 19 Sep 2011)
New Revision: 5369

Modified:
   base/trunk/mpulsweb/lib/security.py
Log:
Added new helper function "checkFeature" which checks if a feature is enabled
in the mpuls_config. If it is not enabled or can not be found raise a 404 by
default.


Modified: base/trunk/mpulsweb/lib/security.py
===================================================================
--- base/trunk/mpulsweb/lib/security.py	2011-09-16 15:06:07 UTC (rev 5368)
+++ base/trunk/mpulsweb/lib/security.py	2011-09-19 14:57:27 UTC (rev 5369)
@@ -42,7 +42,7 @@
 
 from decorator import decorator
 
-from webob.exc import HTTPUnauthorized
+from webob.exc import HTTPUnauthorized, HTTPForbidden, HTTPNotFound
 
 from pylons import request, config, g
 
@@ -420,5 +420,11 @@
     except KeyError:
         return False
 
+def checkFeature(sec, feature):
+    '''Helper function which checks if the feature is enabled in mpuls_config.
+    If not raise an 404 Not Found on default.'''
+    if not g.mpuls_config.is_enabled(sec, feature):
+        raise HTTPNotFound()
+    return True
 
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list