PageRenderTime 11ms CodeModel.GetById 4ms app.highlight 2ms RepoModel.GetById 5ms app.codeStats 0ms

/lib/galaxy/web/controllers/external_services.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 25 lines | 21 code | 4 blank | 0 comment | 4 complexity | c8d6134f71d684d12e31dfe82ea173d8 MD5 | raw file
 1from galaxy.web.base.controller import *
 2from galaxy.model import ExternalService, Sample
 3import logging
 4
 5log = logging.getLogger( __name__ )
 6
 7class_name_to_class = {}
 8
 9for model_class in [Sample]:
10    class_name_to_class[ model_class.__name__ ] = model_class
11
12class ExternalServiceController( BaseUIController ):
13    @web.expose
14    @web.require_admin
15    def access_action( self, trans, external_service_action, item, item_type, **kwd ):
16        if item_type in class_name_to_class:
17            item_type = class_name_to_class.get( item_type )
18            item = item_type.get( item )
19            external_service_action_parsed = external_service_action.split( '|' )
20            populated_external_service = ExternalService.get( external_service_action_parsed.pop( 0 ) ).populate_actions( trans, item )
21            populated_action = populated_external_service.perform_action_by_name( external_service_action_parsed )
22            results = populated_action.handle_results( trans )
23            return results
24        else:
25            raise 'unknown item class type'