| 53 | | == Realm Association of Records == |
| 54 | | |
| 55 | | The "owned_by_entity" field - if present in the table - gets automatically populated in CRUD and Imports, using the auth.set_record_owner method. This method can be influenced by the '''owner_entity''' table hook: |
| 56 | | |
| 57 | | {{{ |
| 58 | | s3db.configure(tablename, |
| 59 | | owner_entity = function_or_lambda) |
| 60 | | }}} |
| 61 | | |
| 62 | | The hook function must accept {{{(table, row)}}} as parameters, and return the pe_id (Person Entity ID) of the owner entity. |
| 63 | | |
| 64 | | It is possible to set a global default for the owner_entity hook in the config.py of the respective template: |
| 65 | | {{{ |
| 66 | | settings.auth.owner_entity = function |
| 67 | | }}} |
| 68 | | |
| 69 | | '''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. |
| 70 | | |