I am saving a masterdictionary of dictionaries to tinydb.
after uploading to an API i extract a copy of a dictionary from the masterdict and make changes, then put it back in the masterdict and put that back in the tinyDB, the next time i access the dictionary, i get the old version.
The second time i make the changes and save it, it works.
Any Ideas?
My code is quite large and I don't think sharing an aia would help (4k blocks).
NOTE:
PCS stands for "plant_check_sheet" and is a dictionary.
PCSMasterDict is a dictionary containing the PCS dictionaries.
The sequence of activity is
make original record dictionary (PCS),
add PCS to PCSMasterDict
add PCSMasterDict to TinyDB['PCS']
iterate PCSMasterDict for each PCS
if PCS[uploaded] = false
send PCS dict to API, (only a reduced version of the PCS is sent)
get back response from POST with PK ( Version A - this contains pk )
get copy of original PCS from PCSMasterDict ( Version B - no pk and it shouldn't)
add "pk" and "uploaded=true" to copy of PCS ( Version C,- B with "pk=PK" and "uploaded=true")
save updated copy of PCS to PCSMasterDict ( Version D - Same as C )
save PCSMasterDict to TinyDB[PCS] ( Version E - Same as C )
At the next iteration of the PCSMasterDict, the key, the value seen is the old (version B) instead of the expected version C with the primary key.
Can anyone see what i am doing wrong?