[session] make hook_control API private
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 29 Mar 2013 12:47:04 +0100
changeset 8840 bd5b5759c9b3
parent 8836 8a57802d40d3
child 8841 f62fb831cfe6
[session] make hook_control API private The doc already says "internal API". The old entry point is now officially deprecated and the context manager have been made private.
server/session.py
--- a/server/session.py	Tue Mar 12 18:31:15 2013 +0100
+++ b/server/session.py	Fri Mar 29 12:47:04 2013 +0100
@@ -87,8 +87,11 @@
         else:
             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)
 
-class hooks_control(object):
+class _hooks_control(object):
     """context manager to control activated hooks categories.
 
     If mode is session.`HOOKS_DENY_ALL`, given hooks categories will
@@ -99,10 +102,10 @@
 
     .. sourcecode:: python
 
-       with hooks_control(self.session, self.session.HOOKS_ALLOW_ALL, 'integrity'):
+       with _hooks_control(self.session, self.session.HOOKS_ALLOW_ALL, 'integrity'):
            # ... do stuff with all but 'integrity' hooks activated
 
-       with hooks_control(self.session, self.session.HOOKS_DENY_ALL, 'integrity'):
+       with _hooks_control(self.session, self.session.HOOKS_DENY_ALL, 'integrity'):
            # ... do stuff with none but 'integrity' hooks activated
 
     This is an internal api, you should rather use
@@ -996,9 +999,9 @@
     # all hooks should be activated during normal execution
 
     def allow_all_hooks_but(self, *categories):
-        return hooks_control(self, HOOKS_ALLOW_ALL, *categories)
+        return _hooks_control(self, HOOKS_ALLOW_ALL, *categories)
     def deny_all_hooks_but(self, *categories):
-        return hooks_control(self, HOOKS_DENY_ALL, *categories)
+        return _hooks_control(self, HOOKS_DENY_ALL, *categories)
 
     hooks_mode = tx_attr('hooks_mode')