5 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/32c6537bef27/ changeset: 32c6537bef27 user: jmchilton date: 2013-02-26 06:09:22 summary: Implement equivalent of dataset display through the API. affected #: 4 files diff -r 993c232d34cda550a5605f87d7416467d4e2c33f -r 32c6537bef27b7d481aed08a7189f11c5161a3ee lib/galaxy/web/__init__.py --- a/lib/galaxy/web/__init__.py +++ b/lib/galaxy/web/__init__.py @@ -2,6 +2,6 @@ The Galaxy web application framework """ -from framework import expose, json, json_pretty, require_login, require_admin, url_for, error, form, FormBuilder, expose_api +from framework import expose, json, json_pretty, require_login, require_admin, url_for, error, form, FormBuilder, expose_api, expose_api_raw from framework.base import httpexceptions diff -r 993c232d34cda550a5605f87d7416467d4e2c33f -r 32c6537bef27b7d481aed08a7189f11c5161a3ee lib/galaxy/web/framework/__init__.py --- a/lib/galaxy/web/framework/__init__.py +++ b/lib/galaxy/web/framework/__init__.py @@ -99,7 +99,14 @@ return decorator return argcatcher -def expose_api( func ): +def expose_api_raw( func ): + """ + Expose this function via the API but don't dump the results + to JSON. + """ + return expose_api( func, to_json=False ) + +def expose_api( func, to_json=True ): @wraps(func) def decorator( self, trans, *args, **kwargs ): def error( environ, start_response ): @@ -183,10 +190,12 @@ trans.response.status = 400 return "That user does not exist." try: - if trans.debug: - return simplejson.dumps( func( self, trans, *args, **kwargs ), indent=4, sort_keys=True ) - else: - return simplejson.dumps( func( self, trans, *args, **kwargs ) ) + rval = func( self, trans, *args, **kwargs) + if to_json and trans.debug: + rval = simplejson.dumps( rval, indent=4, sort_keys=True ) + elif to_json: + rval = simplejson.dumps( rval ) + return rval except paste.httpexceptions.HTTPException: raise # handled except: diff -r 993c232d34cda550a5605f87d7416467d4e2c33f -r 32c6537bef27b7d481aed08a7189f11c5161a3ee lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -125,6 +125,33 @@ 'error' : str( exception ) } + @web.expose_api_raw + def display( self, trans, history_content_id, history_id, preview=False, filename=None, to_ext=None, chunk=None, **kwd ): + """ + GET /api/histories/{encoded_history_id}/contents/{encoded_content_id} + Displays history content (dataset). + """ + hda_dict = {} + try: + # for anon users: + #TODO: check login_required? + #TODO: this isn't actually most_recently_used (as defined in histories) + if( ( trans.user == None ) + and ( history_id == trans.security.encode_id( trans.history.id ) ) ): + history = trans.history + #TODO: dataset/hda by id (from history) OR check_ownership for anon user + hda = self.get_history_dataset_association( trans, history, history_content_id, + check_ownership=False, check_accessible=True ) + + else: + history = self.get_history( trans, history_id, + check_ownership=True, check_accessible=True, deleted=False ) + hda = self.get_history_dataset_association( trans, history, history_content_id, + check_ownership=True, check_accessible=True ) + except: + raise + return hda.datatype.display_data(trans, hda, preview, filename, to_ext, chunk, **kwd) + @web.expose_api def show( self, trans, id, history_id, **kwd ): """ diff -r 993c232d34cda550a5605f87d7416467d4e2c33f -r 32c6537bef27b7d481aed08a7189f11c5161a3ee lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -83,6 +83,11 @@ name_prefix='history_', path_prefix='/api/histories/:history_id', parent_resources=dict( member_name='history', collection_name='histories' ) ) + webapp.api_mapper.connect("history_contents_display", + "/api/histories/:history_id/contents/:history_content_id/display", + controller="history_contents", + action="display", + conditions=dict(method=["GET"])) webapp.api_mapper.resource( 'permission', 'permissions', path_prefix='/api/libraries/:library_id', https://bitbucket.org/galaxy/galaxy-central/commits/3284b58ae9fd/ changeset: 3284b58ae9fd user: jmchilton date: 2013-02-26 16:56:15 summary: Update HDA API return value to reflect new API-based path for downloads. affected #: 1 file diff -r 32c6537bef27b7d481aed08a7189f11c5161a3ee -r 3284b58ae9fd65dd276d0faa2ed930f245c9df5d lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -155,7 +155,7 @@ @web.expose_api def show( self, trans, id, history_id, **kwd ): """ - GET /api/histories/{encoded_history_id}/contents/{encoded_content_id} + GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display Displays information about a history content (dataset). """ hda_dict = {} @@ -230,14 +230,7 @@ hda_dict[ 'file_name' ] = hda.file_name if not hda_dict[ 'deleted' ]: - # Problem: Method url_for cannot use the dataset controller - # Get the environment from DefaultWebTransaction - # and use default webapp mapper instead of webapp API mapper - web_url_for = routes.URLGenerator( trans.webapp.mapper, trans.environ ) - # http://routes.groovie.org/generating.html - # url_for is being phased out, so new applications should use url - hda_dict[ 'download_url' ] = web_url_for( controller='dataset', action='display', - dataset_id=trans.security.encode_id( hda.id ), to_ext=hda.ext ) + hda_dict[ 'download_url' ] = url_for( 'history_contents_display', history_id = trans.security.encode_id( history.id ), history_content_id = trans.security.encode_id( hda.id ) ) can_access_hda = trans.app.security_agent.can_access_dataset( trans.get_current_user_roles(), hda.dataset ) hda_dict[ 'accessible' ] = ( trans.user_is_admin() or can_access_hda ) https://bitbucket.org/galaxy/galaxy-central/commits/440cad876d23/ changeset: 440cad876d23 user: jmchilton date: 2013-02-26 16:59:40 summary: In previous commit, I modified documentation in the wrong place. affected #: 1 file diff -r 3284b58ae9fd65dd276d0faa2ed930f245c9df5d -r 440cad876d23f467bf4ad63ac26a9fe7c4c5eeed lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -128,7 +128,7 @@ @web.expose_api_raw def display( self, trans, history_content_id, history_id, preview=False, filename=None, to_ext=None, chunk=None, **kwd ): """ - GET /api/histories/{encoded_history_id}/contents/{encoded_content_id} + GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display Displays history content (dataset). """ hda_dict = {} @@ -155,7 +155,7 @@ @web.expose_api def show( self, trans, id, history_id, **kwd ): """ - GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display + GET /api/histories/{encoded_history_id}/contents/{encoded_content_id} Displays information about a history content (dataset). """ hda_dict = {} https://bitbucket.org/galaxy/galaxy-central/commits/a2424331a3f9/ changeset: a2424331a3f9 user: jmchilton date: 2013-03-04 17:32:32 summary: Per Jeremy's request I have moved the API history contents dataset display functionality to the dataset controller - https://bitbucket.org/galaxy/galaxy-central/pull-request/131/implement-equiv.... affected #: 3 files diff -r 440cad876d23f467bf4ad63ac26a9fe7c4c5eeed -r a2424331a3f929bfadafea1dedbab5fb4b651472 lib/galaxy/webapps/galaxy/api/datasets.py --- a/lib/galaxy/webapps/galaxy/api/datasets.py +++ b/lib/galaxy/webapps/galaxy/api/datasets.py @@ -4,12 +4,12 @@ import logging, os, string, shutil, urllib, re, socket from galaxy import util, datatypes, jobs, web, util from galaxy.visualization.data_providers.genome import FeatureLocationIndexDataProvider -from galaxy.web.base.controller import BaseAPIController, UsesVisualizationMixin +from galaxy.web.base.controller import BaseAPIController, UsesVisualizationMixin, UsesHistoryDatasetAssociationMixin, UsesHistoryMixin from galaxy.web.framework.helpers import is_true log = logging.getLogger( __name__ ) -class DatasetsController( BaseAPIController, UsesVisualizationMixin ): +class DatasetsController( BaseAPIController, UsesVisualizationMixin, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin ): @web.expose_api def index( self, trans, **kwd ): @@ -191,3 +191,31 @@ data = data_provider.get_data( **kwargs ) return data + + @web.expose_api_raw + def display( self, trans, history_content_id, history_id, preview=False, filename=None, to_ext=None, chunk=None, **kwd ): + """ + GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display + Displays history content (dataset). + """ + # Huge amount of code overlap with lib/galaxy/webapps/galaxy/api/history_content:show here. + hda_dict = {} + try: + # for anon users: + #TODO: check login_required? + #TODO: this isn't actually most_recently_used (as defined in histories) + if( ( trans.user == None ) + and ( history_id == trans.security.encode_id( trans.history.id ) ) ): + history = trans.history + #TODO: dataset/hda by id (from history) OR check_ownership for anon user + hda = self.get_history_dataset_association( trans, history, history_content_id, + check_ownership=False, check_accessible=True ) + + else: + history = self.get_history( trans, history_id, + check_ownership=True, check_accessible=True, deleted=False ) + hda = self.get_history_dataset_association( trans, history, history_content_id, + check_ownership=True, check_accessible=True ) + except: + raise + return hda.datatype.display_data(trans, hda, preview, filename, to_ext, chunk, **kwd) diff -r 440cad876d23f467bf4ad63ac26a9fe7c4c5eeed -r a2424331a3f929bfadafea1dedbab5fb4b651472 lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -125,33 +125,6 @@ 'error' : str( exception ) } - @web.expose_api_raw - def display( self, trans, history_content_id, history_id, preview=False, filename=None, to_ext=None, chunk=None, **kwd ): - """ - GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display - Displays history content (dataset). - """ - hda_dict = {} - try: - # for anon users: - #TODO: check login_required? - #TODO: this isn't actually most_recently_used (as defined in histories) - if( ( trans.user == None ) - and ( history_id == trans.security.encode_id( trans.history.id ) ) ): - history = trans.history - #TODO: dataset/hda by id (from history) OR check_ownership for anon user - hda = self.get_history_dataset_association( trans, history, history_content_id, - check_ownership=False, check_accessible=True ) - - else: - history = self.get_history( trans, history_id, - check_ownership=True, check_accessible=True, deleted=False ) - hda = self.get_history_dataset_association( trans, history, history_content_id, - check_ownership=True, check_accessible=True ) - except: - raise - return hda.datatype.display_data(trans, hda, preview, filename, to_ext, chunk, **kwd) - @web.expose_api def show( self, trans, id, history_id, **kwd ): """ diff -r 440cad876d23f467bf4ad63ac26a9fe7c4c5eeed -r a2424331a3f929bfadafea1dedbab5fb4b651472 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -85,7 +85,7 @@ parent_resources=dict( member_name='history', collection_name='histories' ) ) webapp.api_mapper.connect("history_contents_display", "/api/histories/:history_id/contents/:history_content_id/display", - controller="history_contents", + controller="datasets", action="display", conditions=dict(method=["GET"])) webapp.api_mapper.resource( 'permission', https://bitbucket.org/galaxy/galaxy-central/commits/8236c09e9201/ changeset: 8236c09e9201 user: dannon date: 2013-03-04 18:06:15 summary: Merged in galaxyp/galaxy-central-parallelism-refactorings (pull request #131) Implement equivalent of dataset display through the API. affected #: 5 files Diff not available. 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.