From e60a7ae50eb052b4a2f4f6ad86dd8c93030fa5f2 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Wed, 1 Jul 2020 10:52:10 +0200 Subject: [PATCH 1/3] typo dans le nom de fonction --- halfapi/acl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halfapi/acl.py b/halfapi/acl.py index a540d3e..946e3ed 100644 --- a/halfapi/acl.py +++ b/halfapi/acl.py @@ -5,7 +5,7 @@ class BaseACL: def connected(req, func): """ Decorator that checks if the user object of the request has been set """ - def caller() + def caller(): try: getattr(req.user, 'is_authenticated') return func() From 6b999cdb94a4c8d0921ff3474a39a45ebb0653e0 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Wed, 1 Jul 2020 12:05:52 +0200 Subject: [PATCH 2/3] sortir connected de baseACL --- halfapi/acl.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/halfapi/acl.py b/halfapi/acl.py index 946e3ed..32b83c6 100644 --- a/halfapi/acl.py +++ b/halfapi/acl.py @@ -1,19 +1,19 @@ #!/usr/bin/env python3 +def connected(func): + """ Decorator that checks if the user object of the request has been set + """ + def caller(req, *args, **kwargs): + try: + getattr(req.user, 'is_authenticated') + return func(req, **kwargs) + except AttributeError: + return False + + return caller + class BaseACL: """ Base ACL class that contains generic methods for domains ACL """ - def connected(req, func): - """ Decorator that checks if the user object of the request has been set - """ - def caller(): - try: - getattr(req.user, 'is_authenticated') - return func() - except AttributeError: - return False - - return caller - def public(self, *args) -> bool: "Unlimited access" return True From 906bdb6dedab81e2598377517936c7c45c2ac2e0 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Thu, 2 Jul 2020 10:58:54 +0200 Subject: [PATCH 3/3] passage des ACL en module --- halfapi/acl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/halfapi/acl.py b/halfapi/acl.py index 32b83c6..c222cef 100644 --- a/halfapi/acl.py +++ b/halfapi/acl.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" Base ACL module that contains generic functions for domains ACL +""" + def connected(func): """ Decorator that checks if the user object of the request has been set """ @@ -11,9 +14,6 @@ def connected(func): return caller -class BaseACL: - """ Base ACL class that contains generic methods for domains ACL - """ - def public(self, *args) -> bool: - "Unlimited access" - return True +def public(*args, **kwargs) -> bool: + "Unlimited access" + return True