Skip to content

Closes #18224: Apply all registered request processors when running custom scripts #18225

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

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the removed code line below, is the comment now obsolete? ("If commit is True, wrap it with the event_tracking context manager...")

# 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)
Loading