You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
449 B
18 lines
449 B
|
|
try: |
|
from django_scopes import scope |
|
except ImportError: |
|
from xenua.decorators import no_op as scope |
|
|
|
|
|
def add_scopes(get_scopes=None, **scopes): |
|
def decorate(fn): |
|
def wrapper(*args, **kwargs): |
|
nonlocal scopes |
|
if get_scopes is not None: |
|
scopes = get_scopes(**scopes) |
|
with scope(**scopes): |
|
return fn(*args, **kwargs) |
|
return wrapper |
|
return decorate |
|
|
|
|