[acl decorator] possibility to decorate functions with "@route_acl_decorator"

This commit is contained in:
Maxime Alves LIRMM 2021-05-28 22:22:05 +02:00
parent e4e04c6ac1
commit 8ca94ab7ed
1 changed files with 6 additions and 2 deletions

View File

@ -14,7 +14,7 @@ Exception :
"""
from datetime import datetime
from functools import wraps
from functools import partial, wraps
import logging
from typing import Callable, List, Dict, Generator
from types import ModuleType, FunctionType
@ -33,7 +33,7 @@ class DomainNotFoundError(Exception):
""" Exception when a domain is not importable
"""
def route_acl_decorator(fct: Callable, params: List[Dict]):
def route_acl_decorator(fct: Callable = None, params: List[Dict] = []):
"""
Decorator for async functions that calls pre-conditions functions
and appends kwargs to the target function
@ -50,6 +50,10 @@ def route_acl_decorator(fct: Callable, params: List[Dict]):
async function
"""
if not fct:
return partial(route_acl_decorator, params=params)
@wraps(fct)
async def caller(req: Request, *args, **kwargs):
for param in params: