diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 3df35febcc9..6b45ea6f7fb 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -448,25 +448,26 @@ class Tool: self.fill_in_new_state( trans, self.inputs_by_page[ 0 ], state.inputs ) return state - def fill_in_new_state( self, trans, inputs, state ): + def fill_in_new_state( self, trans, inputs, state, context=None ): """ Fill in a state dictionary with default values taken from input. Grouping elements are filled in recursively. """ + context = ExpressionContext( state, context ) for input in inputs.itervalues(): if isinstance( input, Repeat ): state[ input.name ] = [] elif isinstance( input, Conditional ): s = state[ input.name ] = {} - test_value = input.test_param.get_initial_value( trans, state ) + test_value = input.test_param.get_initial_value( trans, context ) current_case = input.get_current_case( test_value, trans ) - self.fill_in_new_state( trans, input.cases[current_case].inputs, s ) + self.fill_in_new_state( trans, input.cases[current_case].inputs, s, context ) # Store the current case in a special value s['__current_case__'] = current_case # Store the value of the test element s[ input.test_param.name ] = test_value else: - value = input.get_initial_value( trans, state ) + value = input.get_initial_value( trans, context ) state[ input.name ] = value def get_param_html_map( self, trans, page=0, other_values={} ): diff --git a/templates/tool_form.tmpl b/templates/tool_form.tmpl index 17add8eda82..dd46158eccf 100644 --- a/templates/tool_form.tmpl +++ b/templates/tool_form.tmpl @@ -1,4 +1,7 @@ + +#from galaxy.util.expressions import ExpressionContext + @@ -15,7 +18,8 @@

#end if -#def do_inputs( $inputs, $tool_state, $errors, $prefix ) +#def do_inputs( $inputs, $tool_state, $errors, $prefix, $context=None ) + #set $context = ExpressionContext( $tool_state, $context ) #for $input_index, $input in enumerate( $inputs.itervalues() ) #if $input.type == "repeat" #if $input_index > 0 @@ -30,7 +34,7 @@ #set rep_errors = dict() #end if ${input.title} ${i + 1} - $do_inputs( $input.inputs, $repeat_state[$i], $rep_errors, $prefix + $input.name + "_" + str(i) + "|" ) + $do_inputs( $input.inputs, $repeat_state[$i], $rep_errors, $prefix + $input.name + "_" + str(i) + "|", $context ) #end for   @@ -41,19 +45,19 @@ #set group_errors = $errors.get( $input.name, {} ) #set current_case = $group_state['__current_case__'] #set prefix = $prefix + $input.name + "|" - $row_for_param( $prefix, $input.test_param, $group_state, $group_errors, refresh=True ) - $do_inputs( $input.cases[$current_case].inputs, $group_state, $group_errors, $prefix ) + $row_for_param( $prefix, $input.test_param, $group_state, $group_errors, $context, refresh=True ) + $do_inputs( $input.cases[$current_case].inputs, $group_state, $group_errors, $prefix, $context ) #else - $row_for_param( $prefix, $input, $tool_state, $errors ) + $row_for_param( $prefix, $input, $tool_state, $errors, $context ) #end if #end for #end def -#def row_for_param( $prefix, $param, $parent_state, $parent_errors, $refresh=False ) +#def row_for_param( $prefix, $param, $parent_state, $parent_errors, $context, $refresh=False ) $param.get_label(): - #set field = $param.get_html_field( $caller, $parent_state[ $param.name ], $parent_state ) + #set field = $param.get_html_field( $caller, $parent_state[ $param.name ], $context ) #set $field.refresh_on_change = $refresh
$field.get_html( $prefix )
#if $parent_errors.has_key( $param.name ):