Fix for SelectToolParameter  rerun,workflow  when multiple="true"

The following change allows multiple select values to be set on rerun and in 
workflows.   I checked that DrillDownSelectToolParameter and 
ColumnListParameter stiil worked.

$ hg diff lib/galaxy/tools/parameters/basic.py
diff -r 0042b30216fc lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py      Tue Nov 06 11:14:22 2012 -0800
+++ b/lib/galaxy/tools/parameters/basic.py      Mon Dec 10 11:03:10 2012 -0600
@@ -715,6 +715,12 @@
             if value not in legal_values:
                 raise ValueError( "An invalid option was selected, please 
verify" )
             return value
+    def to_html_value( self, value, app ):
+        if isinstance( value, list ):
+            return value
+        else:
+            return str( value )
+
     def to_param_dict_string( self, value, other_values={} ):
         if value is None:
             return "None"





Need to override method to_html_value() from ToolParameter
otherwise a list value will be returned as a string: "['a','b']" instead of a 
list: ['a','b'] and options will not be selected in method get_html_field() :

    def get_html_field( self, trans=None, value=None, context={} ):
        # Dynamic options are not yet supported in workflow, allow
        # specifying the value as text for now.
        if self.need_late_validation( trans, context ):
            if value is not None:
                assert isinstance( value, UnvalidatedValue ), "Late validation 
needed for '%s', but provided value (%s) is not of type UnvalidatedValue (%s)." % ( 
self.name, value, type( value ) )
                value = value.value
            if self.multiple:
                if value is None:
                    value = ""
                else:
                    value = "\n".join( value )
                return form_builder.TextArea( self.name, value=value )
            else:
                return form_builder.TextField( self.name, value=(value or "") )
        if value is not None:
            if not isinstance( value, list ): value = [ value ]       ### "['a','b']"  is 
not a list so value set to ["['a','b']"]
        field = form_builder.SelectField( self.name, self.multiple, 
self.display, self.refresh_on_change, refresh_on_change_values = 
self.refresh_on_change_values )
        options = self.get_options( trans, context )
        for text, optval, selected in options:
            if isinstance( optval, UnvalidatedValue ):
                optval = optval.value
                text = "%s (unvalidated)" % text
            if value:
                selected = ( optval in value )        ### 'a' will not be found in: 
["['a','b']"]
            field.add_option( text, optval, selected )
        return field
diff -r 0042b30216fc lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py      Tue Nov 06 11:14:22 2012 -0800
+++ b/lib/galaxy/tools/parameters/basic.py      Mon Dec 10 11:26:41 2012 -0600
@@ -715,6 +715,12 @@
             if value not in legal_values:
                 raise ValueError( "An invalid option was selected, please 
verify" )
             return value    
+    def to_html_value( self, value, app ):
+        if isinstance( value, list ):
+            return value
+        else:
+            return str( value )
+
     def to_param_dict_string( self, value, other_values={} ):
         if value is None:
             return "None"
___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Reply via email to