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

persist request state into asgi scope extension #1479

Closed
wants to merge 6 commits into from

Conversation

adriangb
Copy link
Member

@adriangb adriangb commented Feb 8, 2022

A possible solution for #495

Not sure this is the best way to do it, it isn't particularly nice, and I can think of other ways to do it.
Some ideas:

  • Create a class RequestState (maybe typing.SimpleNamespace?) and store that in the extension so we assign 1 attribute instead of replacing dict
  • Cleanup around the extension mapping, e.g. using a TypedDict
  • Assign relevant attributes one by one

On the other hand, I think this works for all cases (e.g. creating an HTTPConnection first then a Request or the other way around should work just fine since Request is a subclass of HTTPConnection and thus the mismatched attributes are strictly extra not overlapping)

I'm also not 100% sure this is valid ASGI, the spec is pretty brief on the extensions thing.

@adriangb adriangb added the feature New feature or request label Feb 11, 2022
@adriangb adriangb closed this Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant