| 19 | The "owned_by_entity" field - if present in the table - gets automatically populated in CRUD and Imports (during create), using the auth.set_record_owner method. This method can be influenced by the '''owner_entity''' table hook: |
| 20 | |
| 21 | {{{ |
| 22 | s3db.configure(tablename, |
| 23 | owner_entity = function_or_lambda) |
| 24 | }}} |
| 25 | |
| 26 | The hook function must accept {{{(table, row)}}} as parameters, and return the pe_id (Person Entity ID) of the owner entity. |
| 27 | |
| 28 | It is possible to set a global default for the owner_entity hook in the config.py of the respective template: |
| 29 | {{{ |
| 30 | settings.auth.owner_entity = function |
| 31 | }}} |
| 32 | |
| 33 | '''NOTE:''' the global owner_entity setting overrides any table-specific setting (this is deliberate), i.e. to retain a table specific setting, you must repeat it in the global hook function. |