commit/galaxy-central: carlfeberhard: HDA API: only fetch/return filepaths when user is admin or confing.expose_dataset_path=True (expensive operation)
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/315b484fe81b/ Changeset: 315b484fe81b User: carlfeberhard Date: 2013-09-23 20:32:36 Summary: HDA API: only fetch/return filepaths when user is admin or confing.expose_dataset_path=True (expensive operation) Affected #: 2 files diff -r 87d9c0ca5a4f8ba1f73411ac7f9c23f59ce2cac4 -r 315b484fe81b99954c093b248859a16cd65b4164 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1681,7 +1681,7 @@ rval += child.get_disk_usage( user ) return rval - def to_dict( self, view='collection' ): + def to_dict( self, view='collection', expose_dataset_path=False ): """ Return attributes of this HDA that are exposed using the API. """ @@ -1714,6 +1714,9 @@ for name, spec in hda.metadata.spec.items(): val = hda.metadata.get( name ) if isinstance( val, MetadataFile ): + # only when explicitly set: fetching filepaths can be expensive + if not expose_dataset_path: + continue val = val.file_name # If no value for metadata, look in datatype for metadata. elif val == None and hasattr( hda.datatype, name ): diff -r 87d9c0ca5a4f8ba1f73411ac7f9c23f59ce2cac4 -r 315b484fe81b99954c093b248859a16cd65b4164 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -583,7 +583,8 @@ """ #precondition: the user's access to this hda has already been checked #TODO:?? postcondition: all ids are encoded (is this really what we want at this level?) - hda_dict = hda.to_dict( view='element' ) + expose_dataset_path = trans.user_is_admin() or trans.app.config.expose_dataset_path + hda_dict = hda.to_dict( view='element', expose_dataset_path=expose_dataset_path ) hda_dict[ 'api_type' ] = "file" # Add additional attributes that depend on trans can hence must be added here rather than at the model level. @@ -599,7 +600,7 @@ #TODO: to_dict should really go AFTER this - only summary data return trans.security.encode_dict_ids( hda_dict ) - if trans.user_is_admin() or trans.app.config.expose_dataset_path: + if expose_dataset_path: hda_dict[ 'file_name' ] = hda.file_name hda_dict[ 'download_url' ] = url_for( 'history_contents_display', 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