# HG changeset patch # User Pierre-Yves David # Date 1364398938 -3600 # Node ID 18022ed7c7a57f4bf17236a3fa4aaba8a6cc7243 # Parent 37fd037c05267e195f211e86add79499db7fe342 [session] hook control context directly use transaction object when applicable Most of the hooks control logic have been moved on Transaction anyway. diff -r 37fd037c0526 -r 18022ed7c7a5 server/session.py --- a/server/session.py Wed Mar 27 16:17:21 2013 +0100 +++ b/server/session.py Wed Mar 27 16:42:18 2013 +0100 @@ -113,34 +113,34 @@ def __init__(self, session, mode, *categories): assert mode in (HOOKS_ALLOW_ALL, HOOKS_DENY_ALL) self.session = session + self.tx = session._tx self.mode = mode self.categories = categories self.oldmode = None self.changes = () def __enter__(self): - self.oldmode = self.session._tx.hooks_mode - self.session._tx.hooks_mode = self.mode + self.oldmode = self.tx.hooks_mode + self.tx.hooks_mode = self.mode if self.mode is HOOKS_DENY_ALL: - self.changes = self.session.enable_hook_categories(*self.categories) + self.changes = self.tx.enable_hook_categories(*self.categories) else: - self.changes = self.session.disable_hook_categories(*self.categories) - self.session._tx.ctx_count += 1 + self.changes = self.tx.disable_hook_categories(*self.categories) + self.tx.ctx_count += 1 def __exit__(self, exctype, exc, traceback): - tx = self.session._tx - tx.ctx_count -= 1 - if tx.ctx_count == 0: - self.session._clear_thread_storage(tx) + self.tx.ctx_count -= 1 + if self.tx.ctx_count == 0: + self.session._clear_thread_storage(self.tx) else: try: if self.categories: if self.mode is HOOKS_DENY_ALL: - self.session.disable_hook_categories(*self.categories) + self.tx.disable_hook_categories(*self.categories) else: - self.session.enable_hook_categories(*self.categories) + self.tx.enable_hook_categories(*self.categories) finally: - self.session._tx.hooks_mode = self.oldmode + self.tx.hooks_mode = self.oldmode class security_enabled(object):