#NEWLINE# @ transaction . commit_on_success #NEWLINE# def transition( self , state , event = None , start_time = None , end_time = None , message = None , failed = False , save = True ) : #NEWLINE# #INDENT# 'Create a transition in state. This means of transitioning is the most\n        since this does not involve long-running transitions.\n        ' #NEWLINE# if self . in_transition ( ) : #NEWLINE# #INDENT# raise STSError ( 'Cannot start transition while already in one.' ) #NEWLINE# #UNINDENT# event = Event . get ( event ) #NEWLINE# state = State . get ( state ) #NEWLINE# if ( ( state is None ) or ( state == State . TRANSITION ) ) : #NEWLINE# #INDENT# raise STSError ( 'Cannot create a transition with an empty state.' ) #NEWLINE# #UNINDENT# now = timezone . now ( ) #NEWLINE# if ( start_time is None ) : #NEWLINE# #INDENT# start_time = now #NEWLINE# #UNINDENT# if ( end_time is None ) : #NEWLINE# #INDENT# end_time = now #NEWLINE# #UNINDENT# duration = get_duration ( start_time , end_time ) #NEWLINE# transition = Transition ( system = self , event = event , duration = duration , state = state , start_time = start_time , end_time = end_time , message = message , failed = failed ) #NEWLINE# if save : #NEWLINE# #INDENT# transition . save ( ) #NEWLINE# #UNINDENT# return transition