server/session.py
changeset 9557 a3c075fe9385
parent 9543 39f981482e34
child 9604 eba0e1b033ab
equal deleted inserted replaced
9556:12ee310541bb 9557:a3c075fe9385
   101 
   101 
   102 class _hooks_control(object): # XXX repoapi: remove me when
   102 class _hooks_control(object): # XXX repoapi: remove me when
   103                               # session stop being connection
   103                               # session stop being connection
   104     """context manager to control activated hooks categories.
   104     """context manager to control activated hooks categories.
   105 
   105 
   106     If mode is`HOOKS_DENY_ALL`, given hooks categories will
   106     If mode is `HOOKS_DENY_ALL`, given hooks categories will
   107     be enabled.
   107     be enabled.
   108 
   108 
   109     If mode is `HOOKS_ALLOW_ALL`, given hooks categories will
   109     If mode is `HOOKS_ALLOW_ALL`, given hooks categories will
   110     be disabled.
   110     be disabled.
   111 
   111 
   115            # ... do stuff with all but 'integrity' hooks activated
   115            # ... do stuff with all but 'integrity' hooks activated
   116 
   116 
   117        with _hooks_control(cnx, HOOKS_DENY_ALL, 'integrity'):
   117        with _hooks_control(cnx, HOOKS_DENY_ALL, 'integrity'):
   118            # ... do stuff with none but 'integrity' hooks activated
   118            # ... do stuff with none but 'integrity' hooks activated
   119 
   119 
   120     This is an internal api, you should rather use
   120     This is an internal API, you should rather use
   121     :meth:`~cubicweb.server.session.Connection.deny_all_hooks_but` or
   121     :meth:`~cubicweb.server.session.Connection.deny_all_hooks_but` or
   122     :meth:`~cubicweb.server.session.Connection.allow_all_hooks_but`
   122     :meth:`~cubicweb.server.session.Connection.allow_all_hooks_but`
   123     Transaction methods.
   123     Connection methods.
   124     """
   124     """
   125     def __init__(self, cnx, mode, *categories):
   125     def __init__(self, cnx, mode, *categories):
   126         assert mode in (HOOKS_ALLOW_ALL, HOOKS_DENY_ALL)
   126         assert mode in (HOOKS_ALLOW_ALL, HOOKS_DENY_ALL)
   127         self.cnx = cnx
   127         self.cnx = cnx
   128         self.mode = mode
   128         self.mode = mode