-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closes #20241: Record A & B terminations on cable changelog records #20246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1220d87
to
f5e69e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any concern that providing multiple avenues to modify cable terminations could create conflicts when both approaches operate on the same cable? For example:
# Request 1: UI user editing cable via new approach
cable = Cable.objects.get(pk=1) # On branch X
cable.a_terminations = [interface1]
# ... during double-save process
# Request 2: Plugin or custom script using old approach on same branch
CableTermination.objects.create(
cable_id=1,
cable_end='A',
termination=interface2
)
# Request 1 continues: update_terminations() reconciles based on stale cable state
This seems like it could happen with simultaneous UI/API operations, plugins, or custom scripts that manipulate CableTerminations
directly during the save window.
I realize this is probably rare since most API usage would go through the Cable endpoints anyway, but wanted to check if there should be any safeguards or if this is considered acceptable risk given the benefits.
All modifications typically occur within a transaction bound to the request, so I don't think that's much of a concern. At least, I don't think it's any more of a concern than prior to the change. Tangentially related, there's an effort to discourage the direct modification of cable terminations (see #20295), a mantra which should be extended to custom scripts as well. |
Ah, right, I forgot about that! Thanks for the clarification. |
Closes: #20241
save()
twice for new cables (before and after updating the terminations)_get_x_terminations()
and_set_x_terminations()
methodsget_terminations()
to Cable to return a mapping of all current CableTerminationsupdate_terminations()
method on Cableserialize_object()
on Cable to adda_terminations
andb_terminations
to the change datadeserialize_object()
method (for completeness)