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