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 26, 2018
1 parent aacf134 commit 3094a6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def read(f):
return open(os.path.join(os.path.dirname(__file__), f)).read().strip()

install_requires = ['aiohttp>=0.20', 'jinja2>=2.7']
install_requires = ['aiohttp>=2.3.0', 'jinja2>=2.7']
tests_require = install_requires + ['nose']


Expand Down

0 comments on commit 3094a6d

Please sign in to comment.