equal
deleted
inserted
replaced
1184 * you must use the latest tr info, not entity.in_state for repository side |
1184 * you must use the latest tr info, not entity.in_state for repository side |
1185 checking of the current state |
1185 checking of the current state |
1186 """ |
1186 """ |
1187 def __init__(self, *states): |
1187 def __init__(self, *states): |
1188 def score(entity, states=set(states)): |
1188 def score(entity, states=set(states)): |
1189 trinfo = entity.cw_adapt_to('IWorkflowable').latest_trinfo() |
1189 adapted = entity.cw_adapt_to('IWorkflowable') |
1190 try: |
1190 trinfo = adapted.latest_trinfo() |
1191 return trinfo.new_state.name in states |
1191 if trinfo is None: # entity is probably in it's initial state |
1192 except AttributeError: |
1192 statename = adapted.state |
1193 return None |
1193 else: |
|
1194 statename = trinfo.new_state.name |
|
1195 return statename in states |
1194 super(is_in_state, self).__init__(score) |
1196 super(is_in_state, self).__init__(score) |
1195 |
1197 |
1196 |
1198 |
1197 # logged user selectors ######################################################## |
1199 # logged user selectors ######################################################## |
1198 |
1200 |