def save_workflow(trans, workflow, workflow_dict=None):
 stored = trans.model.StoredWorkflow()
 stored.name = workflow.name
 workflow.stored_workflow = stored
 stored.latest_workflow = workflow
 stored.user = trans.user
 if (workflow_dict and workflow_dict.get('annotation', '')):
  annotation = sanitize_html(workflow_dict['annotation'], 'utf-8', 'text/html')
  new_annotation = trans.model.StoredWorkflowAnnotationAssociation()
  new_annotation.annotation = annotation
  new_annotation.user = trans.user
  stored.annotations.append(new_annotation)
 trans.sa_session.add(stored)
 trans.sa_session.flush()
 if (trans.user.stored_workflow_menu_entries is None):
  trans.user.stored_workflow_menu_entries = []
 menuEntry = trans.model.StoredWorkflowMenuEntry()
 menuEntry.stored_workflow = stored
 trans.user.stored_workflow_menu_entries.append(menuEntry)
 trans.sa_session.flush()
 return stored

def save_workflow ( trans , workflow , workflow_dict = None ) : stored = trans . model . StoredWorkflow ( ) stored . name = workflow . name workflow . stored_workflow = stored stored . latest_workflow = workflow stored . user = trans . user if ( workflow_dict and workflow_dict . get ( 'annotation' , '' ) ) : annotation = sanitize_html ( workflow_dict [ 'annotation' ] , 'utf-8' , 'text/html' ) new_annotation = trans . model . StoredWorkflowAnnotationAssociation ( ) new_annotation . annotation = annotation new_annotation . user = trans . user stored . annotations . append ( new_annotation ) trans . sa_session . add ( stored ) trans . sa_session . flush ( ) if ( trans . user . stored_workflow_menu_entries is None ) : trans . user . stored_workflow_menu_entries = [ ] menuEntry = trans . model . StoredWorkflowMenuEntry ( ) menuEntry . stored_workflow = stored trans . user . stored_workflow_menu_entries . append ( menuEntry ) trans . sa_session . flush ( ) return stored
use the received in-memory workflow object for saving to the galaxy database .