Specifications about state storage in the scope
See original GitHub issueOn Starlette, we store a lot of information on the scope. Outside the extensions scope key. See our auditing: https://github.com/encode/starlette/discussions/1511.
Also, right now I’m writing a documentation on how to write “pure ASGI middlewares” on Starlette: https://github.com/encode/starlette/pull/1656. And a topic related to this appeared: “how should we store context in the scope”?
Should we just use any custom key? If yes, should we add it to the specifications? If no, is extensions the right key? It doesn’t look like, as it seems, that we only use extensions if the ASGI server is participating.
In summary, how should we instruct our users about this topic?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Oscilloscope Specifications: Buying Best Scope
Oscilloscope Specifications: how to buy the best scope ... Scope types includes: Analogue scope Analogue storage scope Digital phosphor scope Digital scope ......
Read more >Creating and using SCOPE=COMMON data spaces - IBM
The SCOPE=COMMON data space provides your programs with virtual storage that is addressable from all address spaces and all programs.
Read more >Storage Classes in C - GeeksforGeeks
Storage Classes are used to describe the features of a variable/function. These features basically include the scope, visibility and life-time ...
Read more >What is the Scope of Computer Data Storage in United kingdom
Every computer has secondary storage along with the RAM, which is where the information is stored permanently. A computer usually has a hard ......
Read more >Standards Portfolio | SNIA
Cloud Data Management Interface (CDMI™) · Computational Storage Architecture and Programming Model · SNIA Emerald™ Power Efficiency Measurement Specification · IP- ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I had always envisaged the scope as something that was just opaquely passed down through each layer - the schema says what keys you can expect to find in it, but doesn’t say that it should not have any others.
However, in the interests of not name-colliding with future scope items, it may be prudent to place all application scope and data under one specific key? Maybe
private, or something like that?I’d suggest using top-level keys: it’s much easier to propagate / copy the dict if you can do a shallow copy instead of having to be aware of nested data structures to copy. So I would suggest a structure like
{"starlette.router": ...}instead of{"starlette": {"router": ...}}.The main con to this is that it’s harder to make a
TypedDictdescribing the framework specific state.