[hg] galaxy 2489: Fix for rendering a form field from a metadata...
details: http://www.bx.psu.edu/hg/galaxy/rev/98ae7a5023c1 changeset: 2489:98ae7a5023c1 user: Greg Von Kuster <greg@bx.psu.edu> date: Wed Jul 22 19:45:03 2009 -0400 description: Fix for rendering a form field from a metadata spec. 2 file(s) affected in this change: lib/galaxy/datatypes/metadata.py lib/galaxy/web/form_builder.py diffs (86 lines): diff -r ecd5fb7ec59b -r 98ae7a5023c1 lib/galaxy/datatypes/metadata.py --- a/lib/galaxy/datatypes/metadata.py Mon Jul 20 16:57:55 2009 -0400 +++ b/lib/galaxy/datatypes/metadata.py Wed Jul 22 19:45:03 2009 -0400 @@ -1,6 +1,6 @@ import sys, logging, copy, shutil, weakref, cPickle, tempfile, os -from galaxy.util import string_as_bool, relpath, stringify_dictionary_keys +from galaxy.util import string_as_bool, relpath, stringify_dictionary_keys, listify from galaxy.util.odict import odict from galaxy.web import form_builder import galaxy.model @@ -138,7 +138,7 @@ def __init__( self, spec ): self.spec = spec - def get_html_field( self, value=None, context={}, other_values={}, **kwd ): + def get_html_field( self, value=None, context={}, other_values={}, **kwd ): return form_builder.TextField( self.spec.name, value=value ) def get_html( self, value, context={}, other_values={}, **kwd ): @@ -256,9 +256,17 @@ value = [value] return ",".join( map( str, value ) ) - def get_html_field( self, value=None, context={}, other_values={}, values=None, **kwd ): + def get_html_field( self, value=None, context={}, other_values={}, values=None, **kwd ): field = form_builder.SelectField( self.spec.name, multiple=self.multiple, display=self.spec.get("display") ) - for val, label in self.values or values or [(val2, val2) for val2 in value]: + if self.values: + value_list = self.values + elif values: + value_list = values + elif value: + value_list = [ ( v, v ) for v in listify( value )] + else: + value_list = [] + for val, label in value_list: try: if ( self.multiple and val in value ) or ( not self.multiple and val == value ): field.add_option( label, val, selected=True ) @@ -266,7 +274,6 @@ field.add_option( label, val, selected=False ) except TypeError: field.add_option( val, label, selected=False ) - return field def get_html( self, value, context={}, other_values={}, values=None, **kwd ): @@ -299,13 +306,12 @@ except KeyError: pass return super(DBKeyParameter, self).get_html_field( value, context, other_values, values, **kwd) - def get_html( self, value=None, context={}, other_values={}, values=None, **kwd): + def get_html( self, value=None, context={}, other_values={}, values=None, **kwd): try: values = kwd['trans'].db_builds except KeyError: pass return super(DBKeyParameter, self).get_html( value, context, other_values, values, **kwd) - class RangeParameter( SelectParameter ): def __init__( self, spec ): diff -r ecd5fb7ec59b -r 98ae7a5023c1 lib/galaxy/web/form_builder.py --- a/lib/galaxy/web/form_builder.py Mon Jul 20 16:57:55 2009 -0400 +++ b/lib/galaxy/web/form_builder.py Wed Jul 22 19:45:03 2009 -0400 @@ -12,9 +12,7 @@ @staticmethod def form_field_types(): return ['TextField', 'TextArea', 'SelectField', 'CheckboxField'] - - - + class TextField(BaseField): """ A standard text input box. @@ -235,8 +233,6 @@ if self.options: return self.options[0] return None - - class DrillDownField( BaseField ): """
participants (1)
-
Greg Von Kuster