[session] fix hooks_control backward compat
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 24 Apr 2013 15:33:49 +0200
changeset 8915 c5c6da8e42db
parent 8912 da2007002dca
child 8916 2a424950463d
[session] fix hooks_control backward compat Session object have no ``hooks_control`` control method. it has ``allow_all_hooks_but`` and ``deny_all_hooks_but`` ones. Regression introduced in bd5b5759c9b3.
server/session.py
--- a/server/session.py	Wed Apr 24 12:10:12 2013 +0200
+++ b/server/session.py	Wed Apr 24 15:33:49 2013 +0200
@@ -88,8 +88,13 @@
             self.session.commit(free_cnxset=self.free_cnxset)
 
 @deprecated('[3.17] use <object>.allow/deny_all_hooks_but instead')
-def hooks_control(obj, *args, **kwargs):
-    return obj.hooks_control(*args, **kwargs)
+def hooks_control(obj, mode, *categories):
+    assert mode in  (HOOKS_ALLOW_ALL, HOOKS_DENY_ALL)
+    if mode == HOOKS_ALLOW_ALL:
+        return obj.allow_all_hooks_but(*categories)
+    elif mode == HOOKS_DENY_ALL:
+        return obj.deny_all_hooks_but(*categories)
+
 
 class _hooks_control(object):
     """context manager to control activated hooks categories.