Skip to content

Commit

Permalink
Upgrade middleware to new style from aiohttp 2.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliya Temusheva committed Jan 25, 2018
1 parent aacf134 commit ad525b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGES
0.15.0 (2017-xx-xx)
-------------------

-
- Upgrade middleware to new style from aiohttp 2.3+

-

Expand Down
17 changes: 8 additions & 9 deletions aiohttp_jinja2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,15 @@ def wrapped(*args):
return wrapper


@web.middleware
@asyncio.coroutine
def context_processors_middleware(app, handler):
@asyncio.coroutine
def middleware(request):
request[REQUEST_CONTEXT_KEY] = {}
for processor in app[APP_CONTEXT_PROCESSORS_KEY]:
request[REQUEST_CONTEXT_KEY].update(
(yield from processor(request)))
return (yield from handler(request))
return middleware
def context_processors_middleware(request, handler):

request[REQUEST_CONTEXT_KEY] = {}
for processor in request.app[APP_CONTEXT_PROCESSORS_KEY]:
request[REQUEST_CONTEXT_KEY].update(
(yield from processor(request)))
return (yield from handler(request))


@asyncio.coroutine
Expand Down

0 comments on commit ad525b6

Please sign in to comment.