commit/galaxy-central: jmchilton: Backout of 28d43f4.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f3dc213a5773/ Changeset: f3dc213a5773 User: jmchilton Date: 2014-02-11 05:13:35 Summary: Backout of 28d43f4. Not quite ready for primetime. Affected #: 2 files diff -r b95d750d1eed64c19c0e31d6683f0f8dca73aeb3 -r f3dc213a5773e356c23915b985803058aeccf9a1 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -16,7 +16,6 @@ from sanitize import ToolParameterSanitizer import validation import dynamic_options -from .dataset_util import DatasetParamContext # For BaseURLToolParameter from galaxy.web import url_for from galaxy.model.item_attrs import Dictifiable @@ -1611,36 +1610,52 @@ self.conversions.append( ( name, conv_extensions, conv_types ) ) def get_html_field( self, trans=None, value=None, other_values={} ): + filter_value = None + if self.options: + try: + filter_value = self.options.get_options( trans, other_values )[0][0] + except IndexError: + pass # no valid options history = self._get_history( trans ) if value is not None: if type( value ) != list: value = [ value ] - dataset_param_context = DatasetParamContext( trans, history, self, value, other_values ) field = form_builder.SelectField( self.name, self.multiple, None, self.refresh_on_change, refresh_on_change_values=self.refresh_on_change_values ) # CRUCIAL: the dataset_collector function needs to be local to DataToolParameter.get_html_field() def dataset_collector( hdas, parent_hid ): + current_user_roles = trans.get_current_user_roles() for i, hda in enumerate( hdas ): hda_name = hda.name if parent_hid is not None: hid = "%s.%d" % ( parent_hid, i + 1 ) else: hid = str( hda.hid ) - valid_hda = dataset_param_context.valid_hda( hda ) - if not valid_hda: - continue - if not valid_hda.implicit_conversion: - selected = dataset_param_context.selected( hda ) - if hda.visible: - hidden_text = "" + if not hda.dataset.state in [galaxy.model.Dataset.states.ERROR, galaxy.model.Dataset.states.DISCARDED] and \ + ( hda.visible or ( value and hda in value and not hda.implicitly_converted_parent_datasets ) ) and \ + trans.app.security_agent.can_access_dataset( current_user_roles, hda.dataset ): + # If we are sending data to an external application, then we need to make sure there are no roles + # associated with the dataset that restrict it's access from "public". + if self.tool and self.tool.tool_type == 'data_destination' and not trans.app.security_agent.dataset_is_public( hda.dataset ): + continue + if self.options and self._options_filter_attribute( hda ) != filter_value: + continue + if hda.datatype.matches_any( self.formats ): + selected = ( value and ( hda in value ) ) + if hda.visible: + hidden_text = "" + else: + hidden_text = " (hidden)" + field.add_option( "%s:%s %s" % ( hid, hidden_text, hda_name ), hda.id, selected ) else: - hidden_text = " (hidden)" - field.add_option( "%s:%s %s" % ( hid, hidden_text, hda_name ), hda.id, selected ) - else: - hda = valid_hda.hda # Get converted dataset - target_ext = valid_hda.target_ext - selected = dataset_param_context.selected( hda ) - field.add_option( "%s: (as %s) %s" % ( hid, target_ext, hda_name ), hda.id, selected ) + target_ext, converted_dataset = hda.find_conversion_destination( self.formats ) + if target_ext: + if converted_dataset: + hda = converted_dataset + if not trans.app.security_agent.can_access_dataset( current_user_roles, hda.dataset ): + continue + selected = ( value and ( hda in value ) ) + field.add_option( "%s: (as %s) %s" % ( hid, target_ext, hda_name ), hda.id, selected ) # Also collect children via association object dataset_collector( hda.children, hid ) dataset_collector( history.active_datasets_children_and_roles, None ) @@ -1672,18 +1687,30 @@ if trans is None or trans.workflow_building_mode or trans.webapp.name == 'tool_shed': return DummyDataset() history = self._get_history( trans, history ) - dataset_param_context = DatasetParamContext( trans, history, self, None, context ) if self.optional: return None most_recent_dataset = [] + filter_value = None + if self.options: + try: + filter_value = self.options.get_options( trans, context )[0][0] + except IndexError: + pass # no valid options def dataset_collector( datasets ): for i, data in enumerate( datasets ): - if data.visible and dataset_param_context.hda_accessible( data, check_security=False ): - match = dataset_param_context.valid_hda_matches_format( data, check_security=False ) - if not match or dataset_param_context.filter( match.hda ): + if data.visible and not data.deleted and data.state not in [data.states.ERROR, data.states.DISCARDED]: + is_valid = False + if data.datatype.matches_any( self.formats ): + is_valid = True + else: + target_ext, converted_dataset = data.find_conversion_destination( self.formats ) + if target_ext: + is_valid = True + if converted_dataset: + data = converted_dataset + if not is_valid or ( self.options and self._options_filter_attribute( data ) != filter_value ): continue - data = match.hda most_recent_dataset.append(data) # Also collect children via association object dataset_collector( data.children ) diff -r b95d750d1eed64c19c0e31d6683f0f8dca73aeb3 -r f3dc213a5773e356c23915b985803058aeccf9a1 lib/galaxy/tools/parameters/dataset_util.py --- a/lib/galaxy/tools/parameters/dataset_util.py +++ /dev/null @@ -1,96 +0,0 @@ -import galaxy.model - -from logging import getLogger -log = getLogger( __name__ ) - -ROLES_UNSET = object() -INVALID_STATES = [ galaxy.model.Dataset.states.ERROR, galaxy.model.Dataset.states.DISCARDED ] - - -class DatasetParamContext( object ): - - def __init__( self, trans, history, param, value, other_values ): - self.trans = trans - self.history = history - self.param = param - self.tool = param.tool - self.value = value - self.current_user_roles = ROLES_UNSET - filter_value = None - if param.options: - try: - filter_value = param.options.get_options( trans, other_values )[0][0] - except IndexError: - pass # no valid options - self.filter_value = filter_value - - def hda_accessible( self, hda, check_security=True ): - dataset = hda.dataset - state_valid = not dataset.state in INVALID_STATES - return state_valid and (not check_security or self.__can_access_dataset( dataset ) ) - - def valid_hda_matches_format( self, hda, check_implicit_conversions=True, check_security=False ): - if self.filter( hda ): - return False - formats = self.param.formats - if hda.datatype.matches_any( formats ): - return ValidParamHdaDirect( hda ) - if not check_implicit_conversions: - return False - target_ext, converted_dataset = hda.find_conversion_destination( formats ) - if target_ext: - if converted_dataset: - hda = converted_dataset - if check_security and not self.__can_access_dataset( hda.dataset ): - return False - return ValidParamHdaImplicit(converted_dataset, target_ext) - return False - - def valid_hda( self, hda, check_implicit_conversions=True ): - accessible = self.hda_accessible( hda ) - if accessible and ( hda.visible or ( self.selected( hda ) and not hda.implicitly_converted_parent_datasets ) ): - # If we are sending data to an external application, then we need to make sure there are no roles - # associated with the dataset that restrict it's access from "public". - require_public = self.tool and self.tool.tool_type == 'data_destination' - if require_public and not self.trans.app.security_agent.dataset_is_public( hda.dataset ): - return False - if self.filter( hda ): - return False - return self.valid_hda_matches_format(hda) - - def selected( self, hda ): - value = self.value - return value and hda in value - - def filter( self, hda ): - param = self.param - return param.options and param._options_filter_attribute( hda ) != self.filter_value - - def __can_access_dataset( self, dataset ): - if self.current_user_roles is ROLES_UNSET: - self.current_user_roles = self.trans.get_current_user_roles() - return self.trans.app.security_agent.can_access_dataset( self.current_user_roles, dataset ) - - -class ValidParamHdaDirect( object ): - - def __init__( self, hda ): - self.hda = hda - - @property - def implicit_conversion( self ): - return False - - -class ValidParamHdaImplicit( object ): - - def __init__( self, converted_dataset, target_ext ): - self.hda = converted_dataset - self.target_ext = target_ext - - @property - def implicit_conversion( self ): - return True - - -__all__ = [ DatasetParamContext ] 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)
-
commits-noreply@bitbucket.org