learningequality/ka-lite — pull request #909 by jamalex (2013-11-02 01:34:26+00:00)
Title: Fix syncing

Depends on #894 (refresh this after merging that -- not many changes in this PR yet).

Haven't completed the testing on this, but it at least fixes the problems that triggered it, and wanted to put it up here since it could relate to the sync errors mentioned by @bcipolli on #894.

Models were being synced, but errors were being reported on the central server side, in the sync session "errors" field. Drilling into that, found that the error was: `{'count': 0, 'error': "get_models() got an unexpected keyword argument 'include_count'"}`, so I added `**kwargs` to absorb this extra param being passed along from the `**kwargs` of the calling function. Then, no more errors, but a syncsession became an infinite loop, as distributed server counters were not being incremented, leading to the same models being downloaded over and over. It seems that the deferred counter incrementing was blocking `increment_counters` from being overridden, so I changed it to only _default_ to incrementing when it's the central server, but still allow for it to be overridden during the import process.