[gen] workflow state: make it performant to write, in a gen-workflow: someState=State(otherState.permissions.copy()).
This commit is contained in:
parent
a16871f4b5
commit
ecb970e519
|
@ -88,14 +88,14 @@ class State:
|
||||||
def standardizeRoles(self):
|
def standardizeRoles(self):
|
||||||
'''This method converts, within self.permissions, every role to a
|
'''This method converts, within self.permissions, every role to a
|
||||||
Role instance. Every used role is stored in self.usedRoles.'''
|
Role instance. Every used role is stored in self.usedRoles.'''
|
||||||
for permission, roles in self.permissions.items():
|
for permission, roles in self.permissions.iteritems():
|
||||||
|
if not roles: continue # Nobody may have this permission
|
||||||
if isinstance(roles, basestring) or isinstance(roles, Role):
|
if isinstance(roles, basestring) or isinstance(roles, Role):
|
||||||
self.permissions[permission] = [self.getRole(roles)]
|
self.permissions[permission] = [self.getRole(roles)]
|
||||||
elif roles:
|
elif isinstance(roles, list):
|
||||||
rolesList = []
|
for i in range(len(roles)): roles[i] = self.getRole(roles[i])
|
||||||
for role in roles:
|
else: # A tuple
|
||||||
rolesList.append(self.getRole(role))
|
self.permissions[permission] = [self.getRole(r) for r in roles]
|
||||||
self.permissions[permission] = rolesList
|
|
||||||
|
|
||||||
def getUsedRoles(self): return self.usedRoles.values()
|
def getUsedRoles(self): return self.usedRoles.values()
|
||||||
|
|
||||||
|
@ -215,8 +215,8 @@ class Transition:
|
||||||
|
|
||||||
def standardiseStates(self, states):
|
def standardiseStates(self, states):
|
||||||
'''Get p_states as a list or a list of lists. Indeed, the user may also
|
'''Get p_states as a list or a list of lists. Indeed, the user may also
|
||||||
specify p_states a tuple or tuple of tuples. Having lists allows us
|
specify p_states as a tuple or tuple of tuples. Having lists allows
|
||||||
to easily perform changes in states if required.'''
|
us to easily perform changes in states if required.'''
|
||||||
if isinstance(states[0], State):
|
if isinstance(states[0], State):
|
||||||
if isinstance(states, tuple): return list(states)
|
if isinstance(states, tuple): return list(states)
|
||||||
return states
|
return states
|
||||||
|
|
Loading…
Reference in a new issue