[session] new methods on session to ease access to security/hooks control context managers stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 19 May 2011 17:53:46 +0200
branchstable
changeset 7405 8c752d113ebb
parent 7404 02a786d7ebce
child 7406 e772a2c57b00
child 7407 a78cc15227ef
[session] new methods on session to ease access to security/hooks control context managers
server/session.py
--- a/server/session.py	Thu May 19 17:53:01 2011 +0200
+++ b/server/session.py	Thu May 19 17:53:46 2011 +0200
@@ -406,6 +406,9 @@
 
     DEFAULT_SECURITY = object() # evaluated to true by design
 
+    def security_enabled(self, read=False, write=False):
+        return security_enabled(self, read=read, write=write)
+
     @property
     def read_security(self):
         """return a boolean telling if read security is activated or not"""
@@ -491,6 +494,11 @@
     HOOKS_ALLOW_ALL = object()
     HOOKS_DENY_ALL = object()
 
+    def allow_all_hooks_but(self, *categories):
+        return hooks_control(self, self.HOOKS_ALLOW_ALL, *categories)
+    def deny_all_hooks_but(self, *categories):
+        return hooks_control(self, self.HOOKS_DENY_ALL, *categories)
+
     @property
     def hooks_mode(self):
         return getattr(self._threaddata, 'hooks_mode', self.HOOKS_ALLOW_ALL)