67 |
67 |
68 Operations |
68 Operations |
69 ~~~~~~~~~~ |
69 ~~~~~~~~~~ |
70 |
70 |
71 Operations are subclasses of the :class:`~cubicweb.server.hook.Operation` class |
71 Operations are subclasses of the :class:`~cubicweb.server.hook.Operation` class |
72 that may be created by hooks and scheduled to happen just before (or after) the |
72 that may be created by hooks and scheduled to happen on `precommit`, |
73 `precommit`, `postcommit` or `rollback` event. Hooks are being fired immediately |
73 `postcommit` or `rollback` event (i.e. respectivly before/after a commit or |
74 on data operations, and it is sometime necessary to delay the actual work down |
74 before a rollback of a transaction). |
75 to a time where all other hooks have run. Also while the order of execution of |
75 |
76 hooks is data dependant (and thus hard to predict), it is possible to force an |
76 Hooks are being fired immediately on data operations, and it is sometime |
77 order on operations. |
77 necessary to delay the actual work down to a time where we can expect all |
|
78 information to be there, or when all other hooks have run (though take case |
|
79 since operations may themselves trigger hooks). Also while the order of |
|
80 execution of hooks is data dependant (and thus hard to predict), it is possible |
|
81 to force an order on operations. |
|
82 |
|
83 So, for such case where you may miss some information that may be set later in |
|
84 the transaction, you should instantiate an operation in the hook. |
78 |
85 |
79 Operations may be used to: |
86 Operations may be used to: |
80 |
87 |
81 * implements a validation check which needs that all relations be already set on |
88 * implements a validation check which needs that all relations be already set on |
82 an entity |
89 an entity |