Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.external_services.result_handlers.basic

import logging
from json import loads

log = logging.getLogger(__name__)


[docs]class ExternalServiceActionResultHandler(object): """ Basic Class for External Service Actions Result Handlers""" type = 'display'
[docs] @classmethod def from_elem(cls, elem, parent): result_type = elem.get('type', None) assert result_type, 'ExternalServiceActionResultHandler requires a type' return result_type_to_class[result_type](elem, parent)
[docs] def __init__(self, elem, parent): self.parent = parent
[docs] def handle_result(self, result, param_dict, trans): return result.content
# need to think about how to restore or set mime type: # both as specified in xml and also as set by an action, # e.g. mimetype returned from web_api action should be reused here...
[docs]class ExternalServiceActionURLRedirectResultHandler(ExternalServiceActionResultHandler): """ Basic Class for External Service Actions Result Handlers""" type = 'web_redirect'
[docs] @classmethod def from_elem(cls, elem, parent): result_type = elem.get('type', None) assert result_type, 'ExternalServiceActionResultHandler requires a type' return result_type_to_class[result_type](elem, parent)
[docs] def __init__(self, elem, parent): self.parent = parent
[docs] def handle_result(self, result, param_dict, trans): return trans.response.send_redirect(result.content)
[docs]class ExternalServiceActionJSONResultHandler(ExternalServiceActionResultHandler): """Class for External Service Actions JQuery Result Handler""" type = 'json_display'
[docs] def handle_result(self, result, param_dict, trans): rval = loads(result.content) return trans.fill_template('/external_services/generic_json.mako', result=rval, param_dict=param_dict, action=self.parent)
[docs]class ExternalServiceActionJQueryGridResultHandler(ExternalServiceActionResultHandler): """Class for External Service Actions JQuery Result Handler""" type = 'jquery_grid'
[docs] def handle_result(self, result, param_dict, trans): rval = loads(result.content) return trans.fill_template('/external_services/generic_jquery_grid.mako', result=rval, param_dict=param_dict, action=self.parent)
result_type_to_class = {} for handler_class in [ExternalServiceActionResultHandler, ExternalServiceActionURLRedirectResultHandler, ExternalServiceActionJQueryGridResultHandler, ExternalServiceActionJSONResultHandler]: result_type_to_class[handler_class.type] = handler_class