Improve the capabilities of UpdateFormMixin for API resources.

Review Request #10370 — Created Jan. 2, 2019 and submitted — Latest diff uploaded


UpdateFormMixin was introduced in Djblets 0.9 to make it easier for
API resources to interface with forms. It offered functionality for
creating instances of forms and to parse data coming in from the API

It was a very useful first step, but left much up to the API resources.
It required the caller to handle much of the request/response data
handling, had no official method for parsing methods to validate and
raise errors, and didn't handle a form's initial data.

This change offers a whole new set of improvements to this mixin. It
makes it easier to construct forms from API requests by automatically
providing all initial field data for the form, so that the caller
doesn't have to, and it provides official support for gathering and
returning errors from parsing methods.

It also wraps much of the existing functionality in some new convenience
methods. Rather than calling create_form(), API resources can now call
handle_form_request(). This takes care of calling create_form(),
checking for form validity, and then returning an error payload or
saving and returning a success payload.

Subclasses can override how these payloads are constructed, perform
additional error payload handling, change how forms are saved, and
manipulate data before or after creating the form. This also
automatically works with the new field validation in the parser methods.

These changes should slim down any resources that use forms
significantly, and make it much easier to maintain resources in a
standard way going forward.

Unit tests pass.

Used all the new functionality in a resource in Review Board and
saw the expected behavior.