commit/galaxy-central: carlfeberhard: Visualization framework: allow plugins to be located outside Galaxy root; fix logging import
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/48fd0ab87841/ Changeset: 48fd0ab87841 User: carlfeberhard Date: 2013-08-06 21:40:17 Summary: Visualization framework: allow plugins to be located outside Galaxy root; fix logging import Affected #: 2 files diff -r 73c9018fcafb9beb2f9fb76bae0a01e1c641b913 -r 48fd0ab87841725fe85726606e187cb728ce9a21 lib/galaxy/visualization/registry.py --- a/lib/galaxy/visualization/registry.py +++ b/lib/galaxy/visualization/registry.py @@ -48,6 +48,7 @@ - validating and parsing params into resources (based on a context) used in the visualization template """ + #: name of this plugin #: any built in visualizations that have their own render method in ctrls/visualization # 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 @@ -57,9 +58,6 @@ 'sweepster', 'phyloviz' ] - #: where to search for visualiztion templates (relative to templates/webapps/galaxy) - # this can be overridden individually in the config entries - TEMPLATE_ROOT = 'visualization' #: directories under plugin_directory that aren't plugins non_plugin_directories = [] @@ -67,7 +65,7 @@ return 'VisualizationsRegistry(%s)' %( self.plugin_directory ) def __init__( self, registry_filepath, template_cache_dir ): - super( VisualizationsRegistry, self ).__init__( registry_filepath, template_cache_dir ) + super( VisualizationsRegistry, self ).__init__( registry_filepath, 'visualizations', template_cache_dir ) # what to use to parse query strings into resources/vars for the template self.resource_parser = ResourceParser() diff -r 73c9018fcafb9beb2f9fb76bae0a01e1c641b913 -r 48fd0ab87841725fe85726606e187cb728ce9a21 lib/galaxy/web/base/pluginframework.py --- a/lib/galaxy/web/base/pluginframework.py +++ b/lib/galaxy/web/base/pluginframework.py @@ -14,6 +14,8 @@ pkg_resources.require( 'Mako' ) import mako +import logging +log = logging.getLogger( __name__ ) # ============================================================================= exceptions class PluginFrameworkException( Exception ): @@ -74,7 +76,13 @@ if not config_plugin_directory: return None try: + # create the plugin path and if plugin dir begins with '/' assume absolute path full_plugin_filepath = os.path.join( config.root, config_plugin_directory ) + if config_plugin_directory.startswith( os.path.sep ): + full_plugin_filepath = config_plugin_directory + if not os.path.exists( full_plugin_filepath ): + raise PluginFrameworkException( 'Plugin path not found: %s' %( full_plugin_filepath ) ) + template_cache = config.template_cache if cls.serves_static else None plugin = cls( full_plugin_filepath, template_cache ) @@ -88,13 +96,22 @@ def __str__( self ): return '%s(%s)' %( self.__class__.__name__, self.plugin_directory ) - def __init__( self, plugin_directory, template_cache_dir=None, debug=False ): + def __init__( self, plugin_directory, name=None, template_cache_dir=None, debug=False ): + """ + :type plugin_directory: string + :param plugin_directory: the base directory where plugin code is kept + :type name: (optional) string (default: None) + :param name: the name of this plugin + (that will appear in url pathing, etc.) + :type template_cache_dir: (optional) string (default: None) + :param template_cache_dir: the cache directory to store compiled mako + """ if not os.path.isdir( plugin_directory ): raise PluginFrameworkException( 'Framework plugin directory not found: %s, %s' %( self.__class__.__name__, plugin_directory ) ) - # absolute (?) path self.plugin_directory = plugin_directory - self.name = os.path.basename( self.plugin_directory ) + #TODO: or pass in from config + self.name = name or os.path.basename( self.plugin_directory ) if self.has_config: self.load_configuration() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org