equal
deleted
inserted
replaced
234 :class:`~cubicweb.server.session.hooks_control` context manager to |
234 :class:`~cubicweb.server.session.hooks_control` context manager to |
235 filter them in or out. Note that ending the transaction with commit() |
235 filter them in or out. Note that ending the transaction with commit() |
236 or rollback() will restore the hooks. |
236 or rollback() will restore the hooks. |
237 |
237 |
238 |
238 |
239 Hooks specific predicate |
239 Hooks specific predicates |
240 ~~~~~~~~~~~~~~~~~~~~~~~~ |
240 ~~~~~~~~~~~~~~~~~~~~~~~~~ |
241 .. autoclass:: cubicweb.server.hook.match_rtype |
241 .. autoclass:: cubicweb.server.hook.match_rtype |
242 .. autoclass:: cubicweb.server.hook.match_rtype_sets |
242 .. autoclass:: cubicweb.server.hook.match_rtype_sets |
243 |
243 |
244 |
244 |
245 Hooks and operations classes |
245 Hooks and operations classes |
471 class match_rtype_sets(ExpectedValuePredicate): |
471 class match_rtype_sets(ExpectedValuePredicate): |
472 """accept if the relation type is in one of the sets given as initializer |
472 """accept if the relation type is in one of the sets given as initializer |
473 argument. The goal of this predicate is that it keeps reference to original sets, |
473 argument. The goal of this predicate is that it keeps reference to original sets, |
474 so modification to thoses sets are considered by the predicate. For instance |
474 so modification to thoses sets are considered by the predicate. For instance |
475 |
475 |
476 MYSET = set() |
476 .. sourcecode:: python |
477 |
477 |
478 class Hook1(Hook): |
478 MYSET = set() |
479 __regid__ = 'hook1' |
479 |
480 __select__ = Hook.__select__ & match_rtype_sets(MYSET) |
480 class Hook1(Hook): |
481 ... |
481 __regid__ = 'hook1' |
482 |
482 __select__ = Hook.__select__ & match_rtype_sets(MYSET) |
483 class Hook2(Hook): |
483 ... |
484 __regid__ = 'hook2' |
484 |
485 __select__ = Hook.__select__ & match_rtype_sets(MYSET) |
485 class Hook2(Hook): |
|
486 __regid__ = 'hook2' |
|
487 __select__ = Hook.__select__ & match_rtype_sets(MYSET) |
486 |
488 |
487 Client code can now change `MYSET`, this will changes the selection criteria |
489 Client code can now change `MYSET`, this will changes the selection criteria |
488 of :class:`Hook1` and :class:`Hook1`. |
490 of :class:`Hook1` and :class:`Hook1`. |
489 """ |
491 """ |
490 |
492 |