sproutcore/sproutcore — pull request #1000 by mirion (2013-06-10 16:11:27+00:00)
Title: Allows the nested store to perform server-side transactions via the data source

In the standard model, a nested store is created in order to make a local transaction. When this transaction is finished, the changes are pushed to the main store and this one forwards them to the server. The problem is that these changes may or may not be accepted by the server. In the case of a refusal (for any reason) the store is into a conflict state (vs the backend). For the sake of consistency and simplicity, the handling of the refusal should be done while the data is into the nested store so the clean data (main store) and the dirty/rejected data (nested store) are clearly separate. This proposal allows the nested store to talk directly to the backend server via the data source and commit the changes to the main store only when these changes are approved by the backend. Of course, this proposal is fully backward compatible (nested stores created using the standard methods are behaving as before) and also, a very important aspect, only the 1st level nested store is allowed to talk to the backend.

I named it autonomous nested store because it is somehow independent from the main stores. It is receiving data from it, but commits to the backend independently and once the commit successful, the main store receives the committed data via a client side commit.

I also attached 2 test cases that are checking that the data flows properly between the different layers.

The final result is a proper separation between the different layers so the main store contains only data that has been approved and committed by the backend server.

Please note that this proposal is not meant to fit all needs but it solves some very particular problems. I'm myself not happy with the current structure of the store/data source but some of the problems could be solved with such corrections. See more comments into this thread: https://groups.google.com/forum/?fromgroups#!topic/sproutcore/3ghJnPGaFAw