commit/galaxy-central: 2 new changesets

2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/44c6cbd425e9/ changeset: 44c6cbd425e9 branch: workflow_import_menu_api user: jmchilton date: 2012-03-19 18:13:59 summary: Augment workflow import api to allow add_to_menu argument which (when true) adds imported workflow to user's workflow menu. Augment api example script to take in an optional fourth parameter --add_to_menu to enable this. affected #: 2 files diff -r f61e924a5463e2f2232635e36d5b2e20745abe24 -r 44c6cbd425e9dc61a5a054d0d417847890e532aa lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -1127,6 +1127,7 @@ # id being imported from a Galaxy tool shed repository. tool_shed_url = kwd.get( 'tool_shed_url', '' ) repository_metadata_id = kwd.get( 'repository_metadata_id', '' ) + add_to_menu = kwd.get( 'add_to_menu', False ) # The workflow_name parameter is in the request only if the import originated # from a Galaxy tool shed, in which case the value was encoded. workflow_name = kwd.get( 'workflow_name', '' ) @@ -1193,7 +1194,7 @@ src = None if cntrller != 'api': src="uploaded file" - workflow, missing_tool_tups = self._workflow_from_dict( trans, data, source=src ) + workflow, missing_tool_tups = self._workflow_from_dict( trans, data, source=src, add_to_menu=add_to_menu ) workflow = workflow.latest_workflow if workflow_name: workflow.name = workflow_name @@ -1824,7 +1825,7 @@ # Add to return value data['steps'][step.order_index] = step_dict return data - def _workflow_from_dict( self, trans, data, source=None ): + def _workflow_from_dict( self, trans, data, source=None, add_to_menu=False ): """ Creates a workflow from a dict. Created workflow is stored in the database and returned. """ @@ -1901,6 +1902,15 @@ # Persist trans.sa_session.add( stored ) trans.sa_session.flush() + + if add_to_menu: + if trans.user.stored_workflow_menu_entries == None: + trans.user.stored_workflow_menu_entries = [] + menuEntry = model.StoredWorkflowMenuEntry() + menuEntry.stored_workflow = stored + trans.user.stored_workflow_menu_entries.append( menuEntry ) + trans.sa_session.flush() + return stored, missing_tool_tups ## ---- Utility methods ------------------------------------------------------- diff -r f61e924a5463e2f2232635e36d5b2e20745abe24 -r 44c6cbd425e9dc61a5a054d0d417847890e532aa scripts/api/workflow_import.py --- a/scripts/api/workflow_import.py +++ b/scripts/api/workflow_import.py @@ -2,7 +2,7 @@ """ Import workflows from the command line. Example calls: -python workflow_import.py <api_key><galaxy_url> '/path/to/workflow/file' +python workflow_import.py <api_key><galaxy_url> '/path/to/workflow/file [--add_to_menu]' """ import os, sys @@ -16,6 +16,8 @@ try: data = {} data['installed_repository_file'] = sys.argv[3] + if len(sys.argv) > 4 and sys.argv[4] == "--add_to_menu": + data['add_to_menu'] = True except IndexError: print 'usage: %s key galaxy_url workflow_file' % os.path.basename(sys.argv[0]) sys.exit(1) https://bitbucket.org/galaxy/galaxy-central/changeset/1a3d01b09f7a/ changeset: 1a3d01b09f7a branch: workflow_import_menu_api user: jmchilton date: 2012-03-19 18:37:37 summary: Improving string vs. bool handling of add_to_menu API option in workflow controller. affected #: 1 file diff -r 44c6cbd425e9dc61a5a054d0d417847890e532aa -r 1a3d01b09f7acf05d465f3eb5906525507a52807 lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -16,6 +16,7 @@ from galaxy.util.topsort import topsort, topsort_levels, CycleError from galaxy.workflow.modules import * from galaxy import model +from galaxy import util from galaxy.model.mapping import desc from galaxy.model.orm import * from galaxy.model.item_attrs import * @@ -1127,7 +1128,7 @@ # id being imported from a Galaxy tool shed repository. tool_shed_url = kwd.get( 'tool_shed_url', '' ) repository_metadata_id = kwd.get( 'repository_metadata_id', '' ) - add_to_menu = kwd.get( 'add_to_menu', False ) + add_to_menu = util.string_as_bool( kwd.get( 'add_to_menu', False ) ) # The workflow_name parameter is in the request only if the import originated # from a Galaxy tool shed, in which case the value was encoded. workflow_name = kwd.get( 'workflow_name', '' ) 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)
-
Bitbucket