-
Notifications
You must be signed in to change notification settings - Fork 16.9k
feat: add a flask_context_manager. #21061
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replaces manual context management and user restoration logic with a unified `flask_context_manager` for better code maintainability and clarity. Removes redundant import of `has_request_context` from multiple modules. Updates `.gitignore` to exclude `.roo/` directory, presumably related to AI Assistant outputs. Signed-off-by: -LAN- <[email protected]>
Signed-off-by: -LAN- <[email protected]>
Eliminates the usage of Flask's `copy_current_request_context` decorator for thread creation across multiple app generators. The change simplifies thread initialization by directly passing necessary context and parameters to the worker function. This refactoring reduces complexity and potential overhead associated with copying request contexts when not required. Signed-off-by: -LAN- <[email protected]>
Simplifies the `flask_context_manager` function by requiring a `contextvars.Context` object instead of an optional mapping of `ContextVar` instances. This change enhances type safety and streamlines the function's usage, ensuring a more consistent and clear interface for managing context variables in Flask applications. Signed-off-by: -LAN- <[email protected]>
Introduces a note in the flask_context_manager function documentation to clarify that while the manager facilitates using current_user across threads and app contexts, directly passing the user in parameters is the preferred approach. Signed-off-by: -LAN- <[email protected]>
QuantumGhost
previously approved these changes
Jun 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other changes LGTM.
Signed-off-by: -LAN- <[email protected]>
Signed-off-by: -LAN- <[email protected]>
Signed-off-by: -LAN- <[email protected]>
QuantumGhost
approved these changes
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
5 tasks
jsincorporated
pushed a commit
to jsincorporated/asaAi
that referenced
this pull request
Jul 8, 2025
Signed-off-by: -LAN- <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
📚 documentation
Improvements or additions to documentation
💪 enhancement
New feature or request
lgtm
This PR has been approved by a maintainer
size:L
This PR changes 100-499 lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: -LAN- [email protected]
Important
Fixes #<issue number>
.Summary
part of #20449
Replaces manual context management and user restoration logic with a
unified
flask_context_manager
for better code maintainability andclarity. Removes redundant import of
has_request_context
frommultiple modules. Updates
.gitignore
to exclude.roo/
directory,presumably related to AI Assistant outputs.
Screenshots
Checklist
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods