From 7b9ab87e383cbdcfbfaeea5f1524b0d4268348e0 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 10 Apr 2026 12:04:48 -0700 Subject: [PATCH] cleanup --- netbox/dcim/signals.py | 11 +++++++++-- netbox/netbox/signals.py | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/signals.py b/netbox/dcim/signals.py index 80c0729c2..2fd394c1a 100644 --- a/netbox/dcim/signals.py +++ b/netbox/dcim/signals.py @@ -171,8 +171,15 @@ def retrace_cable_paths(instance, **kwargs): def retrace_cable_paths_after_raw_create(sender, pks, **kwargs): """ When Cables are created via a raw save, the normal Cable.save() path is bypassed, - so trace_paths is never sent. Retrace paths for all newly created cables once their - CableTerminations have been applied. + so trace_paths is never sent. Retrace paths for all newly created cables. + + Callers must only send this signal after all CableTerminations for the given cables + have been applied. If a cable has no terminations, update_connected_endpoints will + find empty termination lists and skip path creation — so this is safe to call even + if terminations are absent, but path tracing will have no effect. + + Note: raw=False (the default) is intentional here — we explicitly want + update_connected_endpoints to run, unlike during fixture loading (raw=True). """ logger = logging.getLogger('netbox.dcim.cable') for cable in Cable.objects.filter(pk__in=pks): diff --git a/netbox/netbox/signals.py b/netbox/netbox/signals.py index 6837a0c66..4f8ce4b4f 100644 --- a/netbox/netbox/signals.py +++ b/netbox/netbox/signals.py @@ -6,4 +6,6 @@ post_clean = Signal() # Sent after objects of a given model are created via raw save. # Expected call signature: post_raw_create.send(sender=MyModel, pks=[...]) # Provides: pks (list) - PKs of the newly created objects. +# Callers must ensure all related objects (e.g. M2M, dependent rows) are in place +# before sending, as receivers may query related data to perform post-create work. post_raw_create = Signal()