Commit 19a57e3b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Vincent Pelletier

ERP5Security.ERP5UserFactory: cache path instead of object.

otherwise self._person_value's path becomes like /erp5/acl_users/1
instead of /erp5/person_module/1.
parent 829cd9f6
...@@ -49,8 +49,8 @@ class ERP5User(PropertiedUser): ...@@ -49,8 +49,8 @@ class ERP5User(PropertiedUser):
""" User class that checks the object allows acquisition of local roles the """ User class that checks the object allows acquisition of local roles the
ERP5Type way. ERP5Type way.
""" """
_user_value = None _user_path = None
_login_value = None _login_path = None
def getRolesInContext( self, object ): def getRolesInContext( self, object ):
""" Return the list of roles assigned to the user. """ Return the list of roles assigned to the user.
...@@ -202,28 +202,26 @@ class ERP5User(PropertiedUser): ...@@ -202,28 +202,26 @@ class ERP5User(PropertiedUser):
Return the document (ex: Person) corresponding to current user. Return the document (ex: Person) corresponding to current user.
""" """
result = self._user_value result = self._user_path
if result is not None: if result is not None:
return result return self.getPortalObject().unrestrictedTraverse(result)
user_list = [x for x in self.aq_parent.searchUsers( user_list = [x for x in self.aq_parent.searchUsers(
exact_match=True, exact_match=True,
id=self.getId(), id=self.getId(),
) if 'path' in x] ) if 'path' in x]
if user_list: if user_list:
user, = user_list user, = user_list
self._user_value = self.getPortalObject().restrictedTraverse( result = self._user_path = user['path']
user['path'], return self.getPortalObject().unrestrictedTraverse(result)
)
return self._user_value
def getLoginValue(self): def getLoginValue(self):
""" -> login document """ -> login document
Return the document (ex: ERP5 Login) corresponding to current user's login. Return the document (ex: ERP5 Login) corresponding to current user's login.
""" """
result = self._login_value result = self._login_path
if result is not None: if result is not None:
return result return self.getPortalObject().unrestrictedTraverse(result)
user_list = [x for x in self.aq_parent.searchUsers( user_list = [x for x in self.aq_parent.searchUsers(
exact_match=True, exact_match=True,
login=self.getUserName(), login=self.getUserName(),
...@@ -231,10 +229,8 @@ class ERP5User(PropertiedUser): ...@@ -231,10 +229,8 @@ class ERP5User(PropertiedUser):
if user_list: if user_list:
user, = user_list user, = user_list
login, = user['login_list'] login, = user['login_list']
self._login_value = self.getPortalObject().restrictedTraverse( result = self._login_path = login['path']
login['path'], return self.getPortalObject().unrestrictedTraverse(result)
)
return self._login_value
def getLoginValueList(self, portal_type=None, limit=None): def getLoginValueList(self, portal_type=None, limit=None):
""" -> list of login documents """ -> list of login documents
...@@ -249,8 +245,8 @@ class ERP5User(PropertiedUser): ...@@ -249,8 +245,8 @@ class ERP5User(PropertiedUser):
) if 'login_list' in x] ) if 'login_list' in x]
if user_list: if user_list:
user, = user_list user, = user_list
restrictedTraverse = self.getPortalObject().restrictedTraverse unrestrictedTraverse = self.getPortalObject().unrestrictedTraverse
return [restrictedTraverse(x['path']) for x in user['login_list']] return [unrestrictedTraverse(x['path']) for x in user['login_list']]
return [] return []
InitializeClass(ERP5User) InitializeClass(ERP5User)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment