Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples for aiohttp 3.9 #943

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions demo/login_required_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
]
_Handler = Callable[[web.Request], Awaitable[web.StreamResponse]]

user_key = web.AppKey("user", str)

def login_required(fn: _Handler) -> _Handler:
async def wrapped(
Expand All @@ -29,15 +30,15 @@ async def wrapped(
user_id = session["user_id"]
# actually load user from your database (e.g. with aiopg)
user = DATABASE[user_id]
app["user"] = user
app[user_key] = user
return await fn(request, *args, **kwargs)

return wrapped


@login_required
async def handler(request: web.Request) -> web.Response:
user = request.app["user"]
user = request.app[user_key]
return web.Response(text=f"User {user} authorized")


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-e .
aiohttp==3.8.5
aiohttp==3.9.0b1
Dreamsorcerer marked this conversation as resolved.
Show resolved Hide resolved
aiomcache==0.8.1
cryptography==41.0.5
docker==6.1.3
Expand Down
Loading