# HG changeset patch # User Sylvain Thénault # Date 1305820426 -7200 # Node ID 8c752d113ebb943d3e11dc576235dfd54b6d2aef # Parent 02a786d7ebce3c747e231f204d08082b55dd2c4a [session] new methods on session to ease access to security/hooks control context managers diff -r 02a786d7ebce -r 8c752d113ebb 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)