Added optional "principal_id" argument in "get_principal" function
authorThierry Florac <thierry.florac@onf.fr>
Thu, 02 Jun 2016 16:20:29 +0200
changeset 66 f76e2610d4d9
parent 65 e2733978d478
child 67 a6e6f1bc9e22
Added optional "principal_id" argument in "get_principal" function
src/pyams_security/utility.py
--- a/src/pyams_security/utility.py	Thu Jun 02 16:19:18 2016 +0200
+++ b/src/pyams_security/utility.py	Thu Jun 02 16:20:29 2016 +0200
@@ -289,11 +289,12 @@
         return self.cookie.forget(request)
 
 
-def get_principal(request):
+def get_principal(request, principal_id=None):
     """Get principal associated with given request"""
     manager = query_utility(ISecurityManager)
     if manager is not None:
-        principal_id = request.authenticated_userid
+        if principal_id is None:
+            principal_id = request.authenticated_userid
         if principal_id:
             return manager.get_principal(principal_id)
         else: