commit/galaxy-central: dan: Enable dynamic options for DrillDownSelectToolParameter. Fix for setting checked state for current value for DrillDownSelectToolParameter.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/5aab03319761/ changeset: 5aab03319761 user: dan date: 2012-03-29 16:23:42 summary: Enable dynamic options for DrillDownSelectToolParameter. Fix for setting checked state for current value for DrillDownSelectToolParameter. affected #: 2 files diff -r 7273e1405094e931b4dc39f646cf4cd83a5bbc5d -r 5aab033197616ac6d8ca1f14f672f9f3195a56dc lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1133,7 +1133,9 @@ from_file = os.path.join( tool.app.config.tool_data_path, from_file ) elem = XML( "<root>%s</root>" % open( from_file ).read() ) self.is_dynamic = False - self.dynamic_options = None #backwards compatibility with SelectToolParameter's old dynamic options and late validation + self.dynamic_options = elem.get( 'dynamic_options' , None ) + if self.dynamic_options: + self.is_dynamic = True self.options = [] self.filtered = {} if elem.find( 'filter' ): @@ -1148,12 +1150,23 @@ if filter.get( 'value' ) not in self.filtered[filter.get( 'data_ref' )][filter.get( 'meta_key' )]: self.filtered[filter.get( 'data_ref' )][filter.get( 'meta_key' )][filter.get( 'value' )] = [] recurse_option_elems( self.filtered[filter.get( 'data_ref' )][filter.get( 'meta_key' )][filter.get( 'value' )], filter.find( 'options' ).findall( 'option' ) ) - else: + elif not self.dynamic_options: recurse_option_elems( self.options, elem.find( 'options' ).findall( 'option' ) ) + def _get_options_from_code( self, trans=None, value=None, other_values=None ): + assert self.dynamic_options, Exception( "dynamic_options was not specifed" ) + call_other_values = { '__trans__': trans, '__value__': value } + if other_values: + call_other_values.update( other_values.dict ) + return eval( self.dynamic_options, self.tool.code_namespace, call_other_values ) + + def get_options( self, trans=None, value=None, other_values={} ): if self.is_dynamic: - options = [] + if self.dynamic_options: + options = self._get_options_from_code( trans=trans, value=value, other_values=other_values ) + else: + options = [] for filter_key, filter_value in self.filtered.iteritems(): dataset = other_values[filter_key] if dataset.__class__.__name__.endswith( "DatasetFilenameWrapper" ): #this is a bad way to check for this, but problems importing class ( due to circular imports? ) diff -r 7273e1405094e931b4dc39f646cf4cd83a5bbc5d -r 5aab033197616ac6d8ca1f14f672f9f3195a56dc lib/galaxy/web/form_builder.py --- a/lib/galaxy/web/form_builder.py +++ b/lib/galaxy/web/form_builder.py @@ -440,7 +440,7 @@ self.options = options if value and not isinstance( value, list ): value = [ value ] - else: + elif not value: value = [] self.value = value if display == "checkbox": Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket