Skip to content

Commit

Permalink
Closes #18224: Apply all registered request processors when running c…
Browse files Browse the repository at this point in the history
…ustom scripts
  • Loading branch information
jeremystretch committed Dec 16, 2024
1 parent c0fec28 commit 0b9ead3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions netbox/extras/jobs.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging
import traceback
from contextlib import nullcontext
from contextlib import ExitStack

from django.db import transaction
from django.utils.translation import gettext as _

from core.signals import clear_events
from extras.models import Script as ScriptModel
from netbox.context_managers import event_tracking
from netbox.jobs import JobRunner
from netbox.registry import registry
from utilities.exceptions import AbortScript, AbortTransaction
from .utils import is_report

Expand Down Expand Up @@ -100,5 +100,7 @@ def run(self, data, request=None, commit=True, **kwargs):

# Execute the script. If commit is True, wrap it with the event_tracking context manager to ensure we process
# change logging, event rules, etc.
with event_tracking(request) if commit else nullcontext():
with ExitStack() as stack:
for request_processor in registry['request_processors']:
stack.enter_context(request_processor(request))
self.run_script(script, request, data, commit)

0 comments on commit 0b9ead3

Please sign in to comment.