From aa8643014a725bcec016e288f5b434d44586bd2f Mon Sep 17 00:00:00 2001 From: Carl Eberhard Date: Mon, 27 Jul 2015 12:36:20 -0400 Subject: [PATCH] Interactive environments: move static base url from 'visualizations' to 'interactive_environments' for int env plugins --- lib/galaxy/config.py | 2 +- lib/galaxy/visualization/plugins/plugin.py | 6 +++++- lib/galaxy/visualization/plugins/registry.py | 4 ++-- lib/galaxy/web/base/pluginframework.py | 8 ++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index d8ef4f90a75..5fcfa079060 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -436,7 +436,7 @@ class Configuration( object ): self.fluent_log = string_as_bool( kwargs.get( 'fluent_log', False ) ) self.fluent_host = kwargs.get( 'fluent_host', 'localhost' ) self.fluent_port = int( kwargs.get( 'fluent_port', 24224 ) ) - # directory where the visualization/registry searches for plugins + # directory where the visualization registry searches for plugins self.visualization_plugins_directory = kwargs.get( 'visualization_plugins_directory', 'config/plugins/visualizations' ) ie_dirs = kwargs.get( 'interactive_environment_plugins_directory', None ) diff --git a/lib/galaxy/visualization/plugins/plugin.py b/lib/galaxy/visualization/plugins/plugin.py index 81dd0a73a78..16d75c250a2 100644 --- a/lib/galaxy/visualization/plugins/plugin.py +++ b/lib/galaxy/visualization/plugins/plugin.py @@ -119,7 +119,6 @@ class VisualizationPlugin( pluginframework.Plugin, ServesStaticPluginMixin, Serv base_url = context.get( 'base_url', '' ) self.base_url = '/'.join([ base_url, self.name ]) if base_url else self.name - self._set_up_static_plugin() template_cache_dir = context.get( 'template_cache_dir', None ) @@ -252,6 +251,11 @@ class InteractiveEnvironmentPlugin( VisualizationPlugin ): """ INTENV_REQUEST_FACTORY = interactive_environments.InteractiveEnviornmentRequest + def __init__( self, app, path, name, config, context=None, **kwargs ): + # TODO: this is a hack until we can get int envs seperated from the vis reg and into their own framework + context[ 'base_url' ] = 'interactive_environments' + super( InteractiveEnvironmentPlugin, self ).__init__( app, path, name, config, context=context, **kwargs ) + def _render( self, render_vars, trans=None, embedded=None, **kwargs ): """ Override to add interactive environment specific template vars. diff --git a/lib/galaxy/visualization/plugins/registry.py b/lib/galaxy/visualization/plugins/registry.py index 639599922cd..4f30af6ee55 100644 --- a/lib/galaxy/visualization/plugins/registry.py +++ b/lib/galaxy/visualization/plugins/registry.py @@ -31,6 +31,7 @@ class VisualizationsRegistry( pluginframework.PageServingPluginManager ): - validating and parsing params into resources (based on a context) used in the visualization template """ + DEFAULT_BASE_URL = 'visualizations' # these should be handled somewhat differently - and be passed onto their resp. methods in ctrl.visualization # TODO: change/remove if/when they can be updated to use this system #: any built in visualizations that have their own render method in ctrls/visualization @@ -47,8 +48,7 @@ class VisualizationsRegistry( pluginframework.PageServingPluginManager ): def __init__( self, app, skip_bad_plugins=True, **kwargs ): self.app = weakref.ref( app ) self.config_parser = config_parser.VisualizationsConfigParser() - super( VisualizationsRegistry, self ).__init__( app, 'visualizations', - skip_bad_plugins=skip_bad_plugins, **kwargs ) + super( VisualizationsRegistry, self ).__init__( app, skip_bad_plugins=skip_bad_plugins, **kwargs ) def is_plugin( self, plugin_path ): """ diff --git a/lib/galaxy/web/base/pluginframework.py b/lib/galaxy/web/base/pluginframework.py index 68ffd27ba7b..c2f323fa45b 100644 --- a/lib/galaxy/web/base/pluginframework.py +++ b/lib/galaxy/web/base/pluginframework.py @@ -364,6 +364,8 @@ class PageServingPluginManager( PluginManager ): """ # TODO: I'm unclear of the utility of this class - it prob. will only have one subclass (vis reg). Fold into? + #: default static url base + DEFAULT_BASE_URL = '' #: does the class need static files served? serves_static = True #: does the class need template files served? @@ -375,7 +377,7 @@ class PageServingPluginManager( PluginManager ): #: name of files to search for additional template lookup directories additional_template_paths_config_filename = 'additional_template_paths.xml' - def __init__( self, app, base_url, template_cache_dir=None, **kwargs ): + def __init__( self, app, base_url='', template_cache_dir=None, **kwargs ): """ Set up the manager and load all plugins. @@ -387,7 +389,9 @@ class PageServingPluginManager( PluginManager ): :param template_cache_dir: filesytem path to the directory where cached templates are kept """ - self.base_url = base_url + self.base_url = base_url or self.DEFAULT_BASE_URL + if not self.base_url: + raise PluginManagerException( 'base_url or DEFAULT_BASE_URL required' ) self.template_cache_dir = template_cache_dir self.additional_template_paths = []