Skip to content
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

Deprecate OBSERVE_REQUEST_CALLBACK setting #1895

Merged
merged 2 commits into from
Mar 18, 2024

Commits on Mar 11, 2024

  1. Simplify default OBSERVE_REQUEST_CALLBACK behavior

    The previous implementation of observe_request(), the default callback
    for OBSERVE_REQUEST_CALLBACK,  was checking for
    DebugToolbar.is_toolbar_request() and returning True only if that method
    returned False.
    
    However, this is actually unneeded, because
    DebugToolbarMiddleware never instruments its own requests.  If
    DebugToolbar.is_toolbar_request() returns True for a given request,
    DebugToolbarMiddleware will return early without performing any
    instrumentation or processing on the request [1].
    
    In this case, the OBSERVE_REQUEST_CALLBACK callback never gets called,
    because it only gets called via the HistoryPanel.get_headers() method
    [2].  The .get_headers() method is only called by DebugToolbarMiddleware
    after the early return mentioned above [3].  Thus if
    OBSERVE_REQUEST_CALLBACK is called, it must be the case that
    DebugToolbar.is_toolbar_request() is False for the current request.
    Therefore observe_request() can be simplified to always return True
    without changing its behavior.
    
    [1] https://github.com/jazzband/django-debug-toolbar/blob/c688ce4ad7d18c5ecb800869298ca8cf6c08be1d/debug_toolbar/middleware.py#L48-L49
    [2] https://github.com/jazzband/django-debug-toolbar/blob/c688ce4ad7d18c5ecb800869298ca8cf6c08be1d/debug_toolbar/panels/history/panel.py#L23-L29
    [3] https://github.com/jazzband/django-debug-toolbar/blob/c688ce4ad7d18c5ecb800869298ca8cf6c08be1d/debug_toolbar/middleware.py#L76-L77
    living180 committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    68039c6 View commit details
    Browse the repository at this point in the history
  2. Deprecate OBSERVE_REQUEST_CALLBACK

    With the addition of the UPDATE_ON_FETCH setting, the
    OBSERVE_REQUEST_CALLBACK setting is redundant.  Thus add a check
    debug_toolbar.W008 to warn if it is present in DEBUG_TOOLBAR_CONFIG,
    but do not remove it yet.
    
    See jazzband#1886
    living180 committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    cfbad48 View commit details
    Browse the repository at this point in the history