commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/caaf7db30954/ Changeset: caaf7db30954 User: jmchilton Date: 2012-12-14 21:51:20 Summary: Allow display application parameters to be defined with allow_override="True". If parameter X is defined with allow_override="True", then if the dataset link contains the query parameter app_X="foo", the display parameter X will be set to foo regardless of the template text. Affected #: 3 files diff -r eae248415389203907b5b951f139a200024ae069 -r caaf7db309547d9633e9619c89b33fb7e90a92c4 lib/galaxy/datatypes/display_applications/application.py --- a/lib/galaxy/datatypes/display_applications/application.py +++ b/lib/galaxy/datatypes/display_applications/application.py @@ -57,14 +57,17 @@ rval[ key ] = value rval[ DEFAULT_DATASET_NAME ] = data #always have the display dataset name available return rval - def build_parameter_dict( self, data, dataset_hash, user_hash, trans ): + def build_parameter_dict( self, data, dataset_hash, user_hash, trans, app_kwds ): other_values = self.get_inital_values( data, trans ) other_values[ 'DATASET_HASH' ] = dataset_hash other_values[ 'USER_HASH' ] = user_hash for name, param in self.parameters.iteritems(): assert name not in other_values, "The display parameter '%s' has been defined more than once." % name if param.ready( other_values ): - other_values[ name ] = param.get_value( other_values, dataset_hash, user_hash, trans )#subsequent params can rely on this value + if name in app_kwds and param.allow_override: + other_values[ name ] = app_kwds[ name ] + else: + other_values[ name ] = param.get_value( other_values, dataset_hash, user_hash, trans )#subsequent params can rely on this value else: other_values[ name ] = None return False, other_values #need to stop here, next params may need this value @@ -120,13 +123,13 @@ return iter( self.links ) class PopulatedDisplayApplicationLink( object ): - def __init__( self, display_application_link, data, dataset_hash, user_hash, trans ): + def __init__( self, display_application_link, data, dataset_hash, user_hash, trans, app_kwds ): self.link = display_application_link self.data = data self.dataset_hash = dataset_hash self.user_hash = user_hash self.trans = trans - self.ready, self.parameters = self.link.build_parameter_dict( self.data, self.dataset_hash, self.user_hash, trans ) + self.ready, self.parameters = self.link.build_parameter_dict( self.data, self.dataset_hash, self.user_hash, trans, app_kwds ) def display_ready( self ): return self.ready def get_param_value( self, name ): @@ -184,9 +187,9 @@ version = "1.0.0" self.version = version self.links = odict() - def get_link( self, link_name, data, dataset_hash, user_hash, trans ): + def get_link( self, link_name, data, dataset_hash, user_hash, trans, app_kwds ): #returns a link object with data knowledge to generate links - return PopulatedDisplayApplicationLink( self.links[ link_name ], data, dataset_hash, user_hash, trans ) + return PopulatedDisplayApplicationLink( self.links[ link_name ], data, dataset_hash, user_hash, trans, app_kwds ) def filter_by_dataset( self, data, trans ): filtered = DisplayApplication( self.id, self.name, self.datatypes_registry, version = self.version ) for link_name, link_value in self.links.iteritems(): diff -r eae248415389203907b5b951f139a200024ae069 -r caaf7db309547d9633e9619c89b33fb7e90a92c4 lib/galaxy/datatypes/display_applications/parameters.py --- a/lib/galaxy/datatypes/display_applications/parameters.py +++ b/lib/galaxy/datatypes/display_applications/parameters.py @@ -28,6 +28,7 @@ self.viewable = string_as_bool( elem.get( 'viewable', 'False' ) ) #only allow these to be viewed via direct url when explicitly set to viewable self.strip = string_as_bool( elem.get( 'strip', 'False' ) ) self.strip_https = string_as_bool( elem.get( 'strip_https', 'False' ) ) + self.allow_override = string_as_bool( elem.get( 'allow_override', 'False' ) ) # Passing query param app_<name>=<value> to dataset controller allows override if this is true. def get_value( self, other_values, dataset_hash, user_hash, trans ): raise Exception, 'Unimplemented' def prepare( self, other_values, dataset_hash, user_hash, trans ): @@ -126,7 +127,7 @@ def __init__( self, elem, link ): DisplayApplicationParameter.__init__( self, elem, link ) - self.text = elem.text + self.text = elem.text or '' def get_value( self, other_values, dataset_hash, user_hash, trans ): value = fill_template( self.text, context = other_values ) if self.strip: diff -r eae248415389203907b5b951f139a200024ae069 -r caaf7db309547d9633e9619c89b33fb7e90a92c4 lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -719,6 +719,12 @@ @web.expose def display_application( self, trans, dataset_id=None, user_id=None, app_name = None, link_name = None, app_action = None, action_param = None, **kwds ): """Access to external display applications""" + # Build list of parameters to pass in to display application logic (app_kwds) + app_kwds = {} + for name, value in dict(kwds).iteritems(): # clone kwds because we remove stuff as we go. + if name.startswith( "app_" ): + app_kwds[ name[ len( "app_" ): ] ] = value + del kwds[ name ] if kwds: log.debug( "Unexpected Keywords passed to display_application: %s" % kwds ) #route memory? #decode ids @@ -742,7 +748,7 @@ display_app = trans.app.datatypes_registry.display_applications.get( app_name ) assert display_app, "Unknown display application has been requested: %s" % app_name dataset_hash, user_hash = encode_dataset_user( trans, data, user ) - display_link = display_app.get_link( link_name, data, dataset_hash, user_hash, trans ) + display_link = display_app.get_link( link_name, data, dataset_hash, user_hash, trans, app_kwds ) assert display_link, "Unknown display link has been requested: %s" % link_name if data.state == data.states.ERROR: msg.append( ( 'This dataset is in an error state, you cannot view it at an external display application.', 'error' ) ) https://bitbucket.org/galaxy/galaxy-central/commits/3e6f22a221eb/ Changeset: 3e6f22a221eb User: dannon Date: 2013-08-07 19:27:58 Summary: Merged in jmchilton/galaxy-central-display-application-parameters (pull request #99) Display Application Parameter Enhancements Affected #: 3 files diff -r 6e13df4bc3f0e73b69ba510cc626c62145b0a81c -r 3e6f22a221eb521dddcb13bb7c1a07b4b9551932 lib/galaxy/datatypes/display_applications/application.py --- a/lib/galaxy/datatypes/display_applications/application.py +++ b/lib/galaxy/datatypes/display_applications/application.py @@ -57,14 +57,17 @@ rval[ key ] = value rval[ DEFAULT_DATASET_NAME ] = data #always have the display dataset name available return rval - def build_parameter_dict( self, data, dataset_hash, user_hash, trans ): + def build_parameter_dict( self, data, dataset_hash, user_hash, trans, app_kwds ): other_values = self.get_inital_values( data, trans ) other_values[ 'DATASET_HASH' ] = dataset_hash other_values[ 'USER_HASH' ] = user_hash for name, param in self.parameters.iteritems(): assert name not in other_values, "The display parameter '%s' has been defined more than once." % name if param.ready( other_values ): - other_values[ name ] = param.get_value( other_values, dataset_hash, user_hash, trans )#subsequent params can rely on this value + if name in app_kwds and param.allow_override: + other_values[ name ] = app_kwds[ name ] + else: + other_values[ name ] = param.get_value( other_values, dataset_hash, user_hash, trans )#subsequent params can rely on this value else: other_values[ name ] = None return False, other_values #need to stop here, next params may need this value @@ -120,13 +123,13 @@ return iter( self.links ) class PopulatedDisplayApplicationLink( object ): - def __init__( self, display_application_link, data, dataset_hash, user_hash, trans ): + def __init__( self, display_application_link, data, dataset_hash, user_hash, trans, app_kwds ): self.link = display_application_link self.data = data self.dataset_hash = dataset_hash self.user_hash = user_hash self.trans = trans - self.ready, self.parameters = self.link.build_parameter_dict( self.data, self.dataset_hash, self.user_hash, trans ) + self.ready, self.parameters = self.link.build_parameter_dict( self.data, self.dataset_hash, self.user_hash, trans, app_kwds ) def display_ready( self ): return self.ready def get_param_value( self, name ): @@ -184,9 +187,9 @@ version = "1.0.0" self.version = version self.links = odict() - def get_link( self, link_name, data, dataset_hash, user_hash, trans ): + def get_link( self, link_name, data, dataset_hash, user_hash, trans, app_kwds ): #returns a link object with data knowledge to generate links - return PopulatedDisplayApplicationLink( self.links[ link_name ], data, dataset_hash, user_hash, trans ) + return PopulatedDisplayApplicationLink( self.links[ link_name ], data, dataset_hash, user_hash, trans, app_kwds ) def filter_by_dataset( self, data, trans ): filtered = DisplayApplication( self.id, self.name, self.datatypes_registry, version = self.version ) for link_name, link_value in self.links.iteritems(): diff -r 6e13df4bc3f0e73b69ba510cc626c62145b0a81c -r 3e6f22a221eb521dddcb13bb7c1a07b4b9551932 lib/galaxy/datatypes/display_applications/parameters.py --- a/lib/galaxy/datatypes/display_applications/parameters.py +++ b/lib/galaxy/datatypes/display_applications/parameters.py @@ -28,6 +28,7 @@ self.viewable = string_as_bool( elem.get( 'viewable', 'False' ) ) #only allow these to be viewed via direct url when explicitly set to viewable self.strip = string_as_bool( elem.get( 'strip', 'False' ) ) self.strip_https = string_as_bool( elem.get( 'strip_https', 'False' ) ) + self.allow_override = string_as_bool( elem.get( 'allow_override', 'False' ) ) # Passing query param app_<name>=<value> to dataset controller allows override if this is true. def get_value( self, other_values, dataset_hash, user_hash, trans ): raise Exception, 'Unimplemented' def prepare( self, other_values, dataset_hash, user_hash, trans ): @@ -126,7 +127,7 @@ def __init__( self, elem, link ): DisplayApplicationParameter.__init__( self, elem, link ) - self.text = elem.text + self.text = elem.text or '' def get_value( self, other_values, dataset_hash, user_hash, trans ): value = fill_template( self.text, context = other_values ) if self.strip: diff -r 6e13df4bc3f0e73b69ba510cc626c62145b0a81c -r 3e6f22a221eb521dddcb13bb7c1a07b4b9551932 lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -720,6 +720,12 @@ @web.expose def display_application( self, trans, dataset_id=None, user_id=None, app_name = None, link_name = None, app_action = None, action_param = None, **kwds ): """Access to external display applications""" + # Build list of parameters to pass in to display application logic (app_kwds) + app_kwds = {} + for name, value in dict(kwds).iteritems(): # clone kwds because we remove stuff as we go. + if name.startswith( "app_" ): + app_kwds[ name[ len( "app_" ): ] ] = value + del kwds[ name ] if kwds: log.debug( "Unexpected Keywords passed to display_application: %s" % kwds ) #route memory? #decode ids @@ -743,7 +749,7 @@ display_app = trans.app.datatypes_registry.display_applications.get( app_name ) assert display_app, "Unknown display application has been requested: %s" % app_name dataset_hash, user_hash = encode_dataset_user( trans, data, user ) - display_link = display_app.get_link( link_name, data, dataset_hash, user_hash, trans ) + display_link = display_app.get_link( link_name, data, dataset_hash, user_hash, trans, app_kwds ) assert display_link, "Unknown display link has been requested: %s" % link_name if data.state == data.states.ERROR: msg.append( ( 'This dataset is in an error state, you cannot view it at an external display application.', 'error' ) ) 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