Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[pull] dev from plotly:dev #271

Merged
merged 4 commits into from
Oct 25, 2024
Merged

[pull] dev from plotly:dev #271

merged 4 commits into from
Oct 25, 2024

Conversation

pull[bot]
Copy link

@pull pull bot commented Oct 25, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

Copy link

sourcery-ai bot commented Oct 25, 2024

Reviewer's Guide by Sourcery

This PR adds request context data (cookies, headers, path, remote address, and origin) to the callback context, making it accessible in both regular and background callbacks. The implementation includes new properties in the CallbackContext class and modifications to how context is handled in background callbacks.

Sequence diagram for setting and using cookies in callbacks

sequenceDiagram
    actor User
    participant App as Dash App
    participant Callback as Callback Function
    User->>App: Click 'set-cookies' button
    App->>Callback: Trigger set_cookies callback
    Callback->>App: Set cookie 'bg-cookie'
    User->>App: Click 'use-cookies' button
    App->>Callback: Trigger use_cookies callback
    Callback->>App: Retrieve 'bg-cookie' from cookies
    App->>User: Display 'cookie-value' in output
Loading

Updated class diagram for CallbackContext

classDiagram
    class CallbackContext {
        +cookies
        +headers
        +path
        +remote
        +origin
    }
    note for CallbackContext "New properties added to access request context data."
Loading

File-Level Changes

Change Details Files
Added new request context properties to CallbackContext
  • Added cookies property to access request cookies
  • Added headers property to access request headers
  • Added path property to access full request path
  • Added remote property to access remote address
  • Added origin property to access request origin
  • Created helper function _get_from_context for property access
dash/_callback_context.py
Modified background callback context handling
  • Simplified context value creation by copying entire context
  • Removed manual context attribute copying
  • Added cleanup of background-specific context attributes
dash/_callback.py
Added request context initialization in dispatch
  • Added cookies initialization from flask request
  • Added headers initialization from flask request
  • Added path, remote, and origin initialization from flask request
dash/dash.py
Added integration tests for new context features
  • Created test app for cookies in background callbacks
  • Added test case for setting and retrieving cookies
tests/integration/long_callback/app_ctx_cookies.py
tests/integration/long_callback/test_ctx_cookies.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pull pull bot added the ⤵️ pull label Oct 25, 2024
@pull pull bot merged commit 0d9cd2c into admariner:dev Oct 25, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant