| 124 | You can define methods to be invoked after a record has been created/updated, by using: |
| 125 | |
| 126 | {{{ |
| 127 | s3xrc.model.configure(table, create_onaccept=callback) |
| 128 | }}} |
| 129 | {{{ |
| 130 | s3xrc.model.configure(table, update_onaccept=callback) |
| 131 | }}} |
| 132 | |
| 133 | where: |
| 134 | |
| 135 | - '''table''' is the respective DB table |
| 136 | - '''callable''' is the callback setting, see [#Callbacks Callbacks] |
| 137 | |
| 138 | If either of {{{create_onaccept}}} or {{{update_onaccept}}} is not set, then the {{{onaccept}}} setting is tried: |
| 139 | |
| 140 | {{{ |
| 141 | s3xrc.model.configure(table, onaccept=callback) |
| 142 | }}} |
| 143 | |
| 144 | This allows you to define a common onaccept callback for both ''create'' and ''update''. |
| 145 | |
| 146 | The {{{onaccept}}} callbacks are meant to perform extra post-processing of the newly created/updated record (e.g. to update dependent records). The callback functions receive the respective '''record''' as first and only parameter, while their return value will be ignored. |
| 147 | |
| 149 | |
| 150 | You can define methods to be invoked after a record has been deleted, by using: |
| 151 | |
| 152 | {{{ |
| 153 | s3xrc.model.configure(table, ondelete=callback) |
| 154 | }}} |
| 155 | |
| 156 | where: |
| 157 | |
| 158 | - '''table''' is the respective DB table |
| 159 | - '''callable''' is the callback setting, see [#Callbacks Callbacks] |
| 160 | |
| 161 | The {{{ondelete}}} callbacks are meant to perform extra post-processing of the deleted record (e.g. to update dependent records). The callback functions receive the respective '''record''' as first and only parameter, while their return value will be ignored. |
| 162 | |
| 163 | Note: |
| 164 | At the time when the callback is invoked, the record is already deleted from the database. |
| 165 | |