[gen] Added a mechanism for caching method calls that are performed several times for displaying a single ui page (ie: field.show methods).

This commit is contained in:
Gaetan Delannay 2013-06-10 00:13:29 +02:00
parent b12ea0a64d
commit 244826194b
4 changed files with 100 additions and 52 deletions

View file

@ -13,7 +13,7 @@ class UserWrapper(AbstractWrapper):
if self.user.has_role('Manager'): return True
return ('view', 'result')
def showName(self):
def showName(tool):
'''Name and first name, by default, are always shown.'''
return True
@ -23,9 +23,9 @@ class UserWrapper(AbstractWrapper):
email = self.email
return email and (email != self.login)
def showRoles(self):
def showRoles(tool):
'''Only the admin can view or edit roles.'''
return self.user.has_role('Manager')
return tool.user.has_role('Manager')
def validateLogin(self, login):
'''Is this p_login valid?'''