Prevent ConditionsField.choice_kwargs from being shared across instances.

Review Request #10408 — Created Feb. 15, 2019 and submitted

chipx86
Djblets
release-1.0.x
de8d2bb...
djblets

ConditionsField.choice_kwargs, which is used to provide custom values
to pass to ConditionChoice instances (for request state or anything
else) was getting shared across multiple ConditionsFields for multiple
instances of the same form. The reason is that the choice_kwargs
wasn't being copied when Form creates instance-specific copies of its
declared form fields.

We now perform the copy, but in the widget (which previously shared
ConditionsField's version). ConditionsField no longer keeps its own
copy, but instead provides a property that wraps the one in the widget.
This ensures there's only ever one version of choice_kwargs that has
to be managed per field per form instance, and that it's always unique
to that instance.

Unit tests pass.

Verified this fixed a bug I was hitting in Review Board unit tests.

david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.0.x (bfcdaf5)
Loading...