1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f3f8ae33a02a/ Changeset: f3f8ae33a02a User: greg Date: 2013-04-04 15:56:24 Summary: Enhance the tool shed repositories API controller with a new method to return an ordered list of changeset revision hash strings that are associated with installable revisions of a repository defined by name and owner. Affected #: 3 files diff -r e587038cd8cb5d29a3c664f3dedfef0f98491918 -r f3f8ae33a02a8eef02c5ecb876bfbcd67060fdc7 lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -31,50 +31,27 @@ """RESTful controller for interactions with repositories in the Tool Shed.""" @web.expose_api_anonymous - def index( self, trans, deleted=False, **kwd ): + def get_ordered_installable_revisions( self, trans, name, owner, **kwd ): """ - GET /api/repositories - Displays a collection (list) of repositories. + GET /api/repository/get_ordered_installable_revisions + + :param name: the name of the Repository + :param owner: the owner of the Repository + + Returns the ordered list of changeset revision hash strings that are associated with installable revisions. As in the changelog, the + list is ordered oldest to newest. """ - # Example URL: http://localhost:9009/api/repositories - repository_dicts = [] - deleted = util.string_as_bool( deleted ) + # Example URL: http://localhost:9009/api/repositories/get_installable_revisions?name=add_column&owner=test try: - query = trans.sa_session.query( trans.app.model.Repository ) \ - .filter( trans.app.model.Repository.table.c.deleted == deleted ) \ - .order_by( trans.app.model.Repository.table.c.name ) \ - .all() - for repository in query: - repository_dict = repository.get_api_value( view='collection', value_mapper=default_repository_value_mapper( trans, repository ) ) - repository_dict[ 'url' ] = web.url_for( controller='repositories', - action='show', - id=trans.security.encode_id( repository.id ) ) - repository_dicts.append( repository_dict ) - return repository_dicts + # Get the repository information. + repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) + encoded_repository_id = trans.security.encode_id( repository.id ) + repo_dir = repository.repo_path( trans.app ) + repo = hg.repository( suc.get_configured_ui(), repo_dir ) + ordered_installable_revisions = suc.get_ordered_downloadable_changeset_revisions( repository, repo ) + return ordered_installable_revisions except Exception, e: - message = "Error in the Tool Shed repositories API in index: %s" % str( e ) - log.error( message, exc_info=True ) - trans.response.status = 500 - return message - - @web.expose_api_anonymous - def show( self, trans, id, **kwd ): - """ - GET /api/repositories/{encoded_repository_id} - Returns information about a repository in the Tool Shed. - - :param id: the encoded id of the Repository object - """ - # Example URL: http://localhost:9009/api/repositories/f9cad7b01a472135 - try: - repository = suc.get_repository_in_tool_shed( trans, id ) - repository_dict = repository.get_api_value( view='element', value_mapper=default_repository_value_mapper( trans, repository ) ) - repository_dict[ 'url' ] = web.url_for( controller='repositories', - action='show', - id=trans.security.encode_id( repository.id ) ) - return repository_dict - except Exception, e: - message = "Error in the Tool Shed repositories API in show: %s" % str( e ) + message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: %s" % str( e ) log.error( message, exc_info=True ) trans.response.status = 500 return message @@ -103,7 +80,7 @@ "url": "/api/repositories/f9cad7b01a472135", "user_id": "f9cad7b01a472135" } - - a dictionary defining the Repsoitory revision (RepositoryMetadata). For example: + - a dictionary defining the Repository revision (RepositoryMetadata). For example: { "changeset_revision": "3a08cc21466f", "downloadable": true, @@ -171,3 +148,52 @@ log.error( message, exc_info=True ) trans.response.status = 500 return message + + @web.expose_api_anonymous + def index( self, trans, deleted=False, **kwd ): + """ + GET /api/repositories + Displays a collection (list) of repositories. + """ + # Example URL: http://localhost:9009/api/repositories + repository_dicts = [] + deleted = util.string_as_bool( deleted ) + try: + query = trans.sa_session.query( trans.app.model.Repository ) \ + .filter( trans.app.model.Repository.table.c.deleted == deleted ) \ + .order_by( trans.app.model.Repository.table.c.name ) \ + .all() + for repository in query: + repository_dict = repository.get_api_value( view='collection', value_mapper=default_repository_value_mapper( trans, repository ) ) + repository_dict[ 'url' ] = web.url_for( controller='repositories', + action='show', + id=trans.security.encode_id( repository.id ) ) + repository_dicts.append( repository_dict ) + return repository_dicts + except Exception, e: + message = "Error in the Tool Shed repositories API in index: %s" % str( e ) + log.error( message, exc_info=True ) + trans.response.status = 500 + return message + + @web.expose_api_anonymous + def show( self, trans, id, **kwd ): + """ + GET /api/repositories/{encoded_repository_id} + Returns information about a repository in the Tool Shed. + + :param id: the encoded id of the Repository object + """ + # Example URL: http://localhost:9009/api/repositories/f9cad7b01a472135 + try: + repository = suc.get_repository_in_tool_shed( trans, id ) + repository_dict = repository.get_api_value( view='element', value_mapper=default_repository_value_mapper( trans, repository ) ) + repository_dict[ 'url' ] = web.url_for( controller='repositories', + action='show', + id=trans.security.encode_id( repository.id ) ) + return repository_dict + except Exception, e: + message = "Error in the Tool Shed repositories API in show: %s" % str( e ) + log.error( message, exc_info=True ) + trans.response.status = 500 + return message diff -r e587038cd8cb5d29a3c664f3dedfef0f98491918 -r f3f8ae33a02a8eef02c5ecb876bfbcd67060fdc7 lib/galaxy/webapps/tool_shed/buildapp.py --- a/lib/galaxy/webapps/tool_shed/buildapp.py +++ b/lib/galaxy/webapps/tool_shed/buildapp.py @@ -79,7 +79,8 @@ webapp.mapper.resource( 'repository', 'repositories', controller='repositories', - collection={ 'get_repository_revision_install_info' : 'GET' }, + collection={ 'get_repository_revision_install_info' : 'GET', + 'get_ordered_installable_revisions' : 'GET' }, name_prefix='repository_', path_prefix='/api', parent_resources=dict( member_name='repository', collection_name='repositories' ) ) diff -r e587038cd8cb5d29a3c664f3dedfef0f98491918 -r f3f8ae33a02a8eef02c5ecb876bfbcd67060fdc7 lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -1121,6 +1121,7 @@ def set_prior_installation_required( repository, required_repository ): """Return True if the received required_repository must be installed before the received repository.""" + # This method is called only from Galaxy when rendering repository dependencies for an installed tool shed repository. required_repository_tup = [ required_repository.tool_shed, required_repository.name, required_repository.owner, required_repository.changeset_revision ] # Get the list of repository dependency tuples associated with the received repository where prior_installation_required is True. required_rd_tups_that_must_be_installed = repository.requires_prior_installation_of 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.