Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
Fix examples to use app.ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
prryplatypus committed Apr 9, 2021
1 parent 86fcde8 commit ff9a5d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/en/guide/basics/listeners.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The two injected arguments are the currently running `Sanic()` instance, and the
:--:1
```python
async def setup_db(app, loop):
app.db = await db_setup()
app.ctx.db = await db_setup()

app.register_listener(setup_db, "before_server_start")
```
Expand All @@ -85,7 +85,7 @@ The `Sanic` app instance also has a convenience decorator.
```python
@app.listener("before_server_start")
async def setup_db(app, loop):
app.db = await db_setup()
app.ctx.db = await db_setup()
```
:---

Expand All @@ -97,7 +97,7 @@ You can shorten the decorator even further. This is helpful if you have an IDE w
```python
@app.before_server_start
async def setup_db(app, loop):
app.db = await db_setup()
app.ctx.db = await db_setup()
```
:---

Expand Down
6 changes: 3 additions & 3 deletions src/zh/guide/basics/listeners.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Note over 进程: 退出

```python
async def setup_db(app, loop):
app.db = await db_setup()
app.ctx.db = await db_setup()

app.register_listener(setup_db, "before_server_start")
```
Expand All @@ -93,7 +93,7 @@ app.register_listener(setup_db, "before_server_start")
```python
@app.listener("before_server_start")
async def setup_db(app, loop):
app.db = await db_setup()
app.ctx.db = await db_setup()
```

:---
Expand All @@ -111,7 +111,7 @@ async def setup_db(app, loop):
```python
@app.before_server_start
async def setup_db(app, loop):
app.db = await db_setup()
app.ctx.db = await db_setup()
```

:---
Expand Down

0 comments on commit ff9a5d0

Please sign in to comment.