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

Tenant context manager #671

Merged
merged 1 commit into from
Feb 28, 2025
Merged

Tenant context manager #671

merged 1 commit into from
Feb 28, 2025

Conversation

byewokko
Copy link
Collaborator

@byewokko byewokko commented Feb 27, 2025

Introducing an utility for easier tenant context switching.

Usage

import asab.contextvars

print(asab.contextvars.Tenant.get())  # LookupError

with asab.contextvars.tenant_context("mytenant"):
	print(asab.contextvars.Tenant.get())  # "mytenant"

print(asab.contextvars.Tenant.get())  # LookupError

@byewokko byewokko added the enhancement New feature or request label Feb 27, 2025
@byewokko byewokko self-assigned this Feb 27, 2025
@byewokko byewokko requested a review from mejroslav February 27, 2025 15:28
Copy link
Contributor

@mejroslav mejroslav left a comment

Choose a reason for hiding this comment

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

This is fine. I would appreciate an example.py / documentation of how to use this.

@byewokko byewokko merged commit ceb72bd into master Feb 28, 2025
10 checks passed
@byewokko byewokko deleted the feature/tenant-context branch February 28, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants