The RootFactory will start traversal right now and every time it hits a ContainerResource that triggers another query.
On my test domain, there isn't enough data that this is an issue, but I can imagine it will be on larger databases.
Only the views in src/sambal/views/domain.py actually exclude nested data, but it still traverses because every time it hits a ContainerResource it triggers another query and constructs child Resources.
I think it will be possible to stop traversal once it hits nested data, but to do so, the Resource would have to look at the request object passed into the constructor. Luckily it is available to the constructor so this should be possible.
This should not be done until there is good test coverage for the existing traversal views. Once that is locked in with tests we can look at improving this.
The RootFactory will start traversal right now and every time it hits a ContainerResource that triggers another query.
On my test domain, there isn't enough data that this is an issue, but I can imagine it will be on larger databases.
Only the views in
src/sambal/views/domain.py
actually exclude nested data, but it still traverses because every time it hits a ContainerResource it triggers another query and constructs child Resources.I think it will be possible to stop traversal once it hits nested data, but to do so, the Resource would have to look at the
request
object passed into the constructor. Luckily it is available to the constructor so this should be possible.