def load(info): girderRoot = info['serverRoot'] histomicsRoot = Webroot(_template) histomicsRoot.updateHtmlVars(girderRoot.vars) histomicsRoot.updateHtmlVars({'title': 'HistomicsTK'}) info['serverRoot'].histomicstk = histomicsRoot info['serverRoot'].girder = girderRoot # create root resource for all REST end points of HistomicsTK resource = DockerResource('HistomicsTK') setattr(info['apiRoot'], resource.resourceName, resource) # load docker images from cache dockerImageModel = ModelImporter.model('docker_image_model', 'slicer_cli_web') dockerCache = dockerImageModel.loadAllImages() # generate REST end points for slicer CLIs of each docker image genRESTEndPointsForSlicerCLIsInDockerCache(resource, dockerCache) # auto-ingest annotations into database when a .anot file is uploaded events.bind('data.process', 'HistomicsTK', process_annotations) events.bind('jobs.job.update.after', resource.resourceName, resource.AddRestEndpoints)
def load(info): girderRoot = info['serverRoot'] histomicsRoot = WebrootHistomicsTK(_template) histomicsRoot.updateHtmlVars(girderRoot.vars) ImageBrowseResource(info['apiRoot']) # The interface is always available under histomicstk and also available # under the specified path. info['serverRoot'].histomicstk = histomicsRoot webrootPath = Setting().get(PluginSettings.HISTOMICSTK_WEBROOT_PATH) setattr(info['serverRoot'], webrootPath, histomicsRoot) info['serverRoot'].girder = girderRoot pluginName = 'HistomicsTK' # create root resource for all REST end points of HistomicsTK resource = HistomicsTKResource(pluginName) setattr(info['apiRoot'], resource.resourceName, resource) # load docker images from cache dockerImageModel = ModelImporter.model('docker_image_model', 'slicer_cli_web') dockerCache = dockerImageModel.loadAllImages() # generate REST end points for slicer CLIs of each docker image genRESTEndPointsForSlicerCLIsInDockerCache(resource, dockerCache) # auto-ingest annotations into database when a .anot file is uploaded events.bind('data.process', pluginName, process_annotations) events.bind('jobs.job.update.after', resource.resourceName, resource.AddRestEndpoints) events.bind('model.job.save', pluginName, _saveJob) def updateWebroot(event): """ If the webroot path setting is changed, bind the new path to the histomicstk webroot resource. """ if event.info.get('key') == PluginSettings.HISTOMICSTK_WEBROOT_PATH: setattr(info['serverRoot'], event.info['value'], histomicsRoot) events.bind('model.setting.save.after', 'histomicstk', updateWebroot)
def load(info): girderRoot = info['serverRoot'] histomicsRoot = WebrootHistomicsTK(_template) histomicsRoot.updateHtmlVars(girderRoot.vars) ImageBrowseResource(info['apiRoot']) # The interface is always available under histomicstk and also available # under the specified path. info['serverRoot'].histomicstk = histomicsRoot webrootPath = Setting().get(PluginSettings.HISTOMICSTK_WEBROOT_PATH) setattr(info['serverRoot'], webrootPath, histomicsRoot) info['serverRoot'].girder = girderRoot pluginName = 'HistomicsTK' # create root resource for all REST end points of HistomicsTK resource = HistomicsTKResource(pluginName) setattr(info['apiRoot'], resource.resourceName, resource) # load docker images from cache dockerImageModel = ModelImporter.model('docker_image_model', 'slicer_cli_web') dockerCache = dockerImageModel.loadAllImages() # generate REST end points for slicer CLIs of each docker image genRESTEndPointsForSlicerCLIsInDockerCache(resource, dockerCache) # auto-ingest annotations into database when a .anot file is uploaded events.bind('data.process', pluginName, process_annotations) events.bind('jobs.job.update.after', resource.resourceName, resource.AddRestEndpoints) events.bind('model.job.save', pluginName, _saveJob) def updateWebroot(event): """ If the webroot path setting is changed, bind the new path to the histomicstk webroot resource. """ if event.info.get('key') == PluginSettings.HISTOMICSTK_WEBROOT_PATH: setattr(info['serverRoot'], event.info['value'], histomicsRoot) events.bind('model.setting.save.after', 'histomicstk', updateWebroot) curConfig = config.getConfig().get('histomicstk', {}) if curConfig.get('restrict_downloads'): # Change some endpoints to require token access endpoints = [ ('collection', 'GET', (':id', 'download')), ('file', 'GET', (':id', 'download')), ('file', 'GET', (':id', 'download', ':name')), ('folder', 'GET', (':id', 'download')), ('item', 'GET', (':id', 'download')), ('resource', 'GET', ('download', )), ('resource', 'POST', ('download', )), ('item', 'GET', (':itemId', 'tiles', 'images', ':image')), ] for resource, method, route in endpoints: cls = getattr(info['apiRoot'], resource) func = cls.getRouteHandler(method, route) if func.accessLevel == 'public': func = access.token(func) cls.removeRoute(method, route) cls.route(method, route, func)