| 1 | = Context = |
| 2 | |
| 3 | A context is a way of defining a filter for a resource by it's links to another resource. |
| 4 | |
| 5 | We access the filters via a common [wiki:S3/FieldSelectors FieldSelector] despite the back-end ther actual linkages varying from being as simple as a foreign key or going through a link table: |
| 6 | * [wiki:S3/FieldSelectors#ContextPaths] |
| 7 | |
| 8 | The context filters are usually defined in the core models ({{{modules/s3db/*.py}}}), like: |
| 9 | {{{ |
| 10 | s3db.configure("project_project", |
| 11 | context = {"location": "location.location_id", |
| 12 | "organisation": "organisation_id", |
| 13 | }, |
| 14 | ) |
| 15 | }}} |
| 16 | |
| 17 | This shows that: |
| 18 | * if we want "All Projects related to Organisation X" then the back-end will do this by using the simple Foreign Key 'organisation_id', although we can access that via {{{(organisation)}}}. |
| 19 | * if we want "All projects related to location Y" then the back-end will do this through the 'location' [wiki:S3/S3Model/ComponentResources Component], although we can access that via {{{(location)}}}. |
| 20 | |
| 21 | Contexts get used a lot by [wiki:S3Profile Profile pages]. |