Skip to content

Commit

Permalink
Mention configure method for initialization needs in Implementing n…
Browse files Browse the repository at this point in the history
…ew Scopes
  • Loading branch information
Enforcer committed Oct 17, 2020
1 parent b088d88 commit cb6d025
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/scopes.rst
Expand Up @@ -74,4 +74,6 @@ Scopes can be retrieved from the injector, as with any other instance. They are
>>> injector.get(CustomScope) is injector.get(CustomScope)
True

Scopes have `configure` method that will be called once per each injector and can be used for any required initialization.

For scopes with a transient lifetime, such as those tied to HTTP requests, the usual solution is to use a thread or greenlet-local cache inside the scope. The scope is "entered" in some low-level code by calling a method on the scope instance that creates this cache. Once the request is complete, the scope is "left" and the cache cleared.

0 comments on commit cb6d025

Please sign in to comment.