1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/8d1b7e28fd60/ changeset: 8d1b7e28fd60 user: jgoecks date: 2012-03-27 19:03:21 summary: Basics for API access to tools: (a) enable tools, tool panel labels, and tool panel sections to be dictified; and (b) add RESTful UI controller tools. Once session-based authentication is enabled in API, controller will be moved to API. affected #: 2 files diff -r f6010ee7c7f8d5a021cba09bbfef937c28265c82 -r 8d1b7e28fd6027d7ef3c69d17592d6d49cdbcc57 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -485,6 +485,13 @@ self.id = elem.get( "id" ) self.version = elem.get( "version" ) or '' self.elems = odict() + + def to_dict( self ): + """ Return a dict that includes section's attributes. """ + section_elts = [] + for key, val in self.elems.items(): + section_elts.append( val.to_dict() ) + return { 'type': 'section', 'id': self.id, 'name': self.name, 'version': self.version, 'elems': section_elts } class ToolSectionLabel( object ): """ @@ -495,6 +502,10 @@ self.text = elem.get( "text" ) self.id = elem.get( "id" ) self.version = elem.get( "version" ) or '' + + def to_dict( self ): + """ Return a dict that includes label's attributes. """ + return { 'type': 'label', 'id': self.id, 'name': self.text, 'version': self.version } class DefaultToolState( object ): """ @@ -2238,6 +2249,11 @@ self.sa_session.add( new_data ) self.sa_session.flush() return primary_datasets + + def to_dict( self, **kwds ): + """ Return dict that includes tool's attributes. """ + return { 'type': 'tool', 'id': self.id, 'name': self.name, + 'version': self.version, 'description': self.description } class DataSourceTool( Tool ): """ diff -r f6010ee7c7f8d5a021cba09bbfef937c28265c82 -r 8d1b7e28fd6027d7ef3c69d17592d6d49cdbcc57 lib/galaxy/web/controllers/tools.py --- /dev/null +++ b/lib/galaxy/web/controllers/tools.py @@ -0,0 +1,32 @@ +from galaxy import config, tools, web, util +from galaxy.web.base.controller import BaseController, BaseUIController + +class ToolsController( BaseUIController ): + """ + RESTful controller for interactions with tools. Once session-based + authentication can be done with API controllers, this will be moved + to be part of the API. + """ + + @web.json + def index( self, trans, **kwds ): + """ + GET /api/tools: returns a list of tools defined by parameters + parameters: + in_panel - if true, tools are returned in panel structure, including sections and labels + """ + in_panel = util.string_as_bool( kwds.get( 'in_panel', 'True' ) ) + if in_panel: + panel_elts = [] + # Taken from tool_menu.mako: + for key, val in self.app.toolbox.tool_panel.items(): + panel_elts.append( val.to_dict() ) + rval = panel_elts + else: + tools = [] + for id, tool in self.app.toolbox.tools_by_id.items(): + tools.append( tool.to_dict() ) + rval = tools + + return rval + \ No newline at end of file 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.