Enable the dynamic registration of context managers for request processing (i.e. event_tracking()) #10567

Closed
opened 2025-12-29 21:33:13 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 11, 2024).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v4.1.8

Feature type

Change to existing functionality

Triage priority

N/A

Proposed functionality

NetBox currently employs its event_tracking() context manager to process events triggered by a request, e.g. for change change logging. This function is invoked explicitly by the CoreMiddleware class.

Instead of calling this function directly, we can register it within NetBox's application registry, and consult the registry for all registered request processors whenever necessary, including within the middleware as well as for other purposes (such as running a background job).

Use case

This approach will enable to us to dynamically register additional request processors, such as those which may be introduced by plugins, without the need for explicit configuration. #18136 raises one such use case.

Database changes

N/A

External dependencies

N/A

Originally created by @jeremystretch on GitHub (Dec 11, 2024). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v4.1.8 ### Feature type Change to existing functionality ### Triage priority N/A ### Proposed functionality NetBox currently employs its [`event_tracking()`](https://github.com/netbox-community/netbox/blob/a15ff294dd95815027575ae65e0483c8ab29ffe6/netbox/netbox/context_managers.py#L8) context manager to process events triggered by a request, e.g. for change change logging. This function is invoked explicitly by the `CoreMiddleware` class. Instead of calling this function directly, we can register it within NetBox's [application registry](https://netboxlabs.com/docs/netbox/en/stable/development/application-registry/), and consult the registry for all registered request processors whenever necessary, including within the middleware as well as for other purposes (such as running a background job). ### Use case This approach will enable to us to dynamically register additional request processors, such as those which may be introduced by plugins, without the need for explicit configuration. #18136 raises one such use case. ### Database changes N/A ### External dependencies N/A
adam added the status: acceptedtype: featurecomplexity: medium labels 2025-12-29 21:33:13 +01:00
adam closed this issue 2025-12-29 21:33:14 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10567