question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specifications about state storage in the scope

See original GitHub issue

On 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?

cc @florimondmanca @tomchristie

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
andrewgodwincommented, Jun 14, 2022

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?

0reactions
adriangbcommented, Jun 14, 2022

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 TypedDict describing the framework specific state.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found