def add_wf_meta(enum): index, item = enum node = nodes[index] wfc = IWorkflowController(node.item, None) if wfc is None: return #!+SCHEDULING_FILTERS(mb, mar-2012) Find a more elegant way to do this # perhaps as a workflow feature if not len(wfc.workflow.get_state_ids(keys=["draft"], restrict=False)): return item["wf_state"] = translate_i18n(wfc.state_controller.get_state().title) item["wf_actions"] = [ dict(value=transition, text=translate_i18n(wfc.workflow.get_transition(transition).title)) for transition in wfc.getFireableTransitionIds() ]
def add_wf_meta(enum): index, item = enum node = nodes[index] item["item_id"] = node.item_id if model_interfaces.IScheduleText.providedBy(node.item): return if not include_wf: return wfc = IWorkflowController(node.item, None) if wfc is None: return item["wf_state"] = translate_i18n( wfc.state_controller.get_state().title) item["wf_actions"] = [ dict(value=transition, text=translate_i18n( wfc.workflow.get_transition(transition).title)) for transition in wfc.getFireableTransitionIds() ]
def schedule_sitting_items(context): # !+fireTransitionToward(mr, dec-2010) sequence of fireTransitionToward # calls was introduced in r5818, 28-jan-2010 -- here the code is reworked # to be somewhat more sane, and added logging of both SUCCESS and of # FAILURE of each call to fireTransitionToward(). # # The check/logging should be removed once it is understood whether # NoTransitionAvailableError is *always* raised (i.e. fireTransitionToward is # broken) or it is indeed raised correctly when it should be. def fireTransitionScheduled(item, wfc, toward): try: wfc.fireTransitionToward(toward, check_security=True) raise RuntimeWarning("It has WORKED !!! fireTransitionToward(%r)" % (toward)) except (NoTransitionAvailableError, RuntimeWarning): debug.log_exc_info(sys.exc_info(), log.error) for schedule in context.items.values(): wfc = IWorkflowController(schedule.item, None) if wfc is None: continue wf = wfc.workflow manager = interfaces.ISchedulingManager(schedule.item, None) if not manager: continue try: for target_state in manager.scheduled_states: if wf.get_state(target_state): fireTransitionScheduled(schedule.item, wfc, target_state) except InvalidStateError: # try to fire to next logical scheduled state if (wfc.state_controller.get_status() in manager.schedulable_states): transition_ids = wfc.getFireableTransitionIds() for transition_id in transition_ids: transition = wf.get_transition(transition_id) if (transition.destination in manager.scheduled_states): fireTransitionScheduled(schedule.item, wfc, toward=transition.destination) break
def add_wf_meta(enum): index, item = enum node = nodes[index] wfc = IWorkflowController(node.item, None) if wfc is None: return #!+SCHEDULING_FILTERS(mb, mar-2012) Find a more elegant way to do this # perhaps as a workflow feature if not len( wfc.workflow.get_state_ids(keys=["draft"], restrict=False)): return item["wf_state"] = translate_i18n( wfc.state_controller.get_state().title) item["wf_actions"] = [ dict(value=transition, text=translate_i18n( wfc.workflow.get_transition(transition).title)) for transition in wfc.getFireableTransitionIds() ]
def schedule_sitting_items(context): # !+fireTransitionToward(mr, dec-2010) sequence of fireTransitionToward # calls was introduced in r5818, 28-jan-2010 -- here the code is reworked # to be somewhat more sane, and added logging of both SUCCESS and of # FAILURE of each call to fireTransitionToward(). # # The check/logging should be removed once it is understood whether # NoTransitionAvailableError is *always* raised (i.e. fireTransitionToward is # broken) or it is indeed raised correctly when it should be. def fireTransitionScheduled(item, wfc, toward=SCHEDULED): try: wfc.fireTransitionToward(toward, check_security=True) raise RuntimeWarning( "It has WORKED !!! fireTransitionToward(%r)" % (toward)) except (NoTransitionAvailableError, RuntimeWarning): debug.log_exc_info(sys.exc_info(), log.error) for schedule in context.items.values(): wfc = IWorkflowController(schedule.item, None) if wfc is None: continue wf = wfc.workflow try: if wf.get_state(SCHEDULED): fireTransitionScheduled(schedule.item, wfc) except InvalidStateError: # try to fire to next logical scheduled state if (wfc.state_controller.get_status() in wfc.workflow.get_state_ids(tagged=[PENDING], restrict=False) ): transition_ids = wfc.getFireableTransitionIds() for transition_id in transition_ids: transition = wf.get_transition(transition_id) if (transition.destination in wfc.workflow.get_state_ids(tagged=[SCHEDULED], restrict=False) ): fireTransitionScheduled(schedule.item, wfc, toward=transition.destination) break
def schedule_sitting_items(context): # !+fireTransitionToward(mr, dec-2010) sequence of fireTransitionToward # calls was introduced in r5818, 28-jan-2010 -- here the code is reworked # to be somewhat more sane, and added logging of both SUCCESS and of # FAILURE of each call to fireTransitionToward(). # # The check/logging should be removed once it is understood whether # NoTransitionAvailableError is *always* raised (i.e. fireTransitionToward is # broken) or it is indeed raised correctly when it should be. def fireTransitionScheduled(item, wfc, toward): try: wfc.fireTransitionToward(toward, check_security=True) raise RuntimeWarning("It has WORKED !!! fireTransitionToward(%r)" % (toward)) except (NoTransitionAvailableError, RuntimeWarning): probing.log_exc_info(sys.exc_info(), log.error) for schedule in context.items.values(): if not IFeatureSchedule.providedBy(schedule.item): continue wfc = IWorkflowController(schedule.item) wf = wfc.workflow schedule_feature = wf.get_feature("schedule") scheduled_states = schedule_feature.get_param("scheduled_states") schedulable_states = schedule_feature.get_param("schedulable_states") try: for target_state in scheduled_states: if wf.get_state(target_state): fireTransitionScheduled(schedule.item, wfc, target_state) except InvalidStateError: # try to fire to next logical scheduled state if schedule.item.status in schedulable_states: # !+is_schedulable transition_ids = wfc.getFireableTransitionIds() for transition_id in transition_ids: transition = wf.get_transition(transition_id) if transition.destination in scheduled_states: fireTransitionScheduled(schedule.item, wfc, toward=transition.destination) break
def add_wf_meta(enum): index, item = enum node = nodes[index] item["item_id"] = node.item_id if model_interfaces.IScheduleText.providedBy(node.item): return if not include_wf: return wfc = IWorkflowController(node.item, None) if wfc is None: return item["wf_state"] = translate_i18n( wfc.state_controller.get_state().title ) item["wf_actions"] = [ dict( value=transition, text=translate_i18n( wfc.workflow.get_transition(transition).title ) ) for transition in wfc.getFireableTransitionIds() ]