]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Add "accessing the app instance" to docs/application.md 620/head
authorLiam O'Boyle <liam@elyobo.net>
Wed, 4 Sep 2019 01:56:26 +0000 (11:56 +1000)
committerLiam O'Boyle <liam@elyobo.net>
Wed, 4 Sep 2019 01:56:26 +0000 (11:56 +1000)
Along the lines of @tomchristie's suggestion in #620 but stressing the
use of `request.app`.

docs/applications.md

index 5c30365f06626c15ca1b1b4d6a274f0f4ffcd5c3..44426448c9ede94fb0496a57116dc8fd30621243 100644 (file)
@@ -80,10 +80,14 @@ exceptions that occur within the application:
 ### Storing state on the app instance
 
 You can store arbitrary extra state on the application instance, using the
-generic `app.state` attribute.  This can then be accessed in middleware or endpoints via `request.app`.
+generic `app.state` attribute.
 
 For example:
 
 ```python
 app.state.ADMIN_EMAIL = 'admin@example.org'
 ```
+
+### Acessing the app instance
+
+Where a `request` is available (i.e. endpoints and middleware), the app is available on `request.app`.  For other situations it can be imported from wherever it's instantiated.