Add enhanced support for extra_data and JSON patching.
Review Request #12251 — Created April 22, 2022 and submitted
This brings some long-needed support for working with modern
extra_datafunctionality in Review Board.
Attempting to modify an
extra_datadictionary now raises an exception.
This is part of the work done to make dictionary fields immutable, since
RBTools doesn't have a concept of simply saving a resource back to the
update()calls are required instead). The immutable error
provides handy instructions for setting new
The big change here, though, is the support for
This was doable before through something like:
That obviously was not ideal. Now, callers can simply set the
extra_data_jsonfield to a native dictionary to do a JSON Merge Patch
extra_data_json_patchto a list of dictionaries to do a JSON
Patch. RBTools will properly serialize the results to JSON, setting the
correct key in the payload.
.copy()method also exists to return a copy of the original field
data, without any wrapping. This works for any dictionary level of
extra_data, allowing consumers to create a copy, manipulate it, and
set it as a new full dictionary in a patch request.
Between new patching options, a more standard dictionary interface, the
ability to copy the payload, and useful immutable error handling, it
should now be a lot easier to work with
Unit tests pass on all supported versions of Python.
Removed some unused variables.
Revision 2 (+924 -112)
Checks run (2 succeeded)