#NEWLINE# def __init__( self , workflow ) : #NEWLINE# #INDENT# super ( Step , self ) . __init__ ( ) #NEWLINE# self . workflow = workflow #NEWLINE# cls = self . __class__ . __name__ #NEWLINE# if ( not ( self . action_class and issubclass ( self . action_class , Action ) ) ) : #NEWLINE# #INDENT# raise AttributeError ( ( 'You must specify an action for %s.' % cls ) ) #NEWLINE# #UNINDENT# self . slug = self . action_class . slug #NEWLINE# self . name = self . action_class . name #NEWLINE# self . permissions = self . action_class . permissions #NEWLINE# self . has_errors = False #NEWLINE# self . _handlers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . connections is None ) : #NEWLINE# #INDENT# self . connections = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# for ( key , handlers ) in self . connections . items ( ) : #NEWLINE# #INDENT# self . _handlers [ key ] = [ ] #NEWLINE# if ( not isinstance ( handlers , ( list , tuple ) ) ) : #NEWLINE# #INDENT# raise TypeError ( ( 'The connection handlers for %s must be a list or tuple.' % cls ) ) #NEWLINE# #UNINDENT# for possible_handler in handlers : #NEWLINE# #INDENT# if callable ( possible_handler ) : #NEWLINE# #INDENT# self . _handlers [ key ] . append ( possible_handler ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( self , basestring ) ) : #NEWLINE# #INDENT# return TypeError ( 'Connection handlers must be either callables or strings.' ) #NEWLINE# #UNINDENT# #UNINDENT# bits = possible_handler . split ( '.' ) #NEWLINE# if ( bits [ 0 ] == 'self' ) : #NEWLINE# #INDENT# root = self #NEWLINE# for bit in bits [ 1 : ] : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# root = getattr ( root , bit ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise AttributeError ( ( 'The connection handler %s could not be found on %s.' % ( possible_handler , cls ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# handler = root #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( bits ) == 1 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Importing a local function as a string is not supported for the connection handler %s on %s.' % ( possible_handler , cls ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# module_name = '.' . join ( bits [ : ( - 1 ) ] ) #NEWLINE# try : #NEWLINE# #INDENT# mod = import_module ( module_name ) #NEWLINE# handler = getattr ( mod , bits [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise ImportError ( ( 'Could not import %s from the module %s as a connection handler on %s.' % ( bits [ ( - 1 ) ] , module_name , cls ) ) ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise AttributeError ( ( 'Could not import %s from the module %s as a connection handler on %s.' % ( bits [ ( - 1 ) ] , module_name , cls ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _handlers [ key ] . append ( handler )