[acl decorator] possibility to decorate functions with "@route_acl_decorator"
This commit is contained in:
parent
e4e04c6ac1
commit
8ca94ab7ed
|
@ -14,7 +14,7 @@ Exception :
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import wraps
|
from functools import partial, wraps
|
||||||
import logging
|
import logging
|
||||||
from typing import Callable, List, Dict, Generator
|
from typing import Callable, List, Dict, Generator
|
||||||
from types import ModuleType, FunctionType
|
from types import ModuleType, FunctionType
|
||||||
|
@ -33,7 +33,7 @@ class DomainNotFoundError(Exception):
|
||||||
""" Exception when a domain is not importable
|
""" 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
|
Decorator for async functions that calls pre-conditions functions
|
||||||
and appends kwargs to the target function
|
and appends kwargs to the target function
|
||||||
|
@ -50,6 +50,10 @@ def route_acl_decorator(fct: Callable, params: List[Dict]):
|
||||||
async function
|
async function
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not fct:
|
||||||
|
return partial(route_acl_decorator, params=params)
|
||||||
|
|
||||||
|
|
||||||
@wraps(fct)
|
@wraps(fct)
|
||||||
async def caller(req: Request, *args, **kwargs):
|
async def caller(req: Request, *args, **kwargs):
|
||||||
for param in params:
|
for param in params:
|
||||||
|
|
Loading…
Reference in New Issue