Got safely request argument

This commit is contained in:
Pedro Crespo-Valero 2018-09-06 03:43:12 +02:00
parent ca38b38a0e
commit 9a4d8fb1ad
1 changed files with 2 additions and 2 deletions

View File

@ -94,7 +94,7 @@ def login_required(fn):
"""
@wraps(fn)
async def wrapped(*args, **kwargs):
request = args[-1]
request = kwargs.get('request', args[-1] if args else None)
if not isinstance(request, web.BaseRequest):
msg = ("Incorrect decorator usage. "
"Expecting `def handler(request)` "
@ -125,7 +125,7 @@ def has_permission(
def wrapper(fn):
@wraps(fn)
async def wrapped(*args, **kwargs):
request = args[-1]
request = kwargs.get('request', args[-1] if args else None)
if not isinstance(request, web.BaseRequest):
msg = ("Incorrect decorator usage. "
"Expecting `def handler(request)` "