[session] new methods on session to ease access to security/hooks control context managers
--- 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)