Loading openflexure_microscope/api/v2/blueprints/plugins.py +4 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): for view_id, view_data in plugin.views.items(): logging.debug(f"Representing view {view_id}") uri = url_for(f"v2_plugins_blueprint.{view_id}") uri = url_for(f"v2_plugins_blueprint.{plugin._name_python_safe}_{view_id}") # Make links dictionary if it doesn't yet exist view_d = {"links": {"self": uri}} Loading Loading @@ -86,7 +86,9 @@ def construct_blueprint(microscope_obj): blueprint.add_url_rule( plugin_view["rule"], view_func=plugin_view["view"].as_view( plugin_view_id, microscope=microscope_obj, plugin=plugin f"{plugin._name_python_safe}_{plugin_view_id}", microscope=microscope_obj, plugin=plugin, ), ) Loading openflexure_microscope/plugins/loader.py +17 −2 Original line number Diff line number Diff line import importlib import copy import os import collections import inspect import logging Loading Loading @@ -258,9 +259,11 @@ class BasePlugin: # Expand the rule to include plugin name full_rule = "/{}/{}".format(self._name_uri_safe, cleaned_rule) # Create a Python-safe route ID view_id = cleaned_rule.replace("/", "_") # Create a Python-safe route ID logging.debug(view_id) # Store route information in a dictionary d = {"rule": full_rule, "view": view_class} Loading @@ -271,10 +274,22 @@ class BasePlugin: @property def gui(self): print(self._gui) # Handle missing/no GUI if not self._gui: return None # Handle GUI as a dictionary-returning callable function elif isinstance(self._gui, collections.Callable): api_gui = self._gui() # Handle GUI as a static dictionary elif isinstance(self._gui, dict): api_gui = copy.deepcopy(self._gui) # Handle borked GUI else: raise ValueError( "GUI must be a dictionary, or a dictionary-returning function with no arguments." ) api_gui["id"] = self._name if "forms" in api_gui and isinstance(api_gui["forms"], list): Loading Loading
openflexure_microscope/api/v2/blueprints/plugins.py +4 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): for view_id, view_data in plugin.views.items(): logging.debug(f"Representing view {view_id}") uri = url_for(f"v2_plugins_blueprint.{view_id}") uri = url_for(f"v2_plugins_blueprint.{plugin._name_python_safe}_{view_id}") # Make links dictionary if it doesn't yet exist view_d = {"links": {"self": uri}} Loading Loading @@ -86,7 +86,9 @@ def construct_blueprint(microscope_obj): blueprint.add_url_rule( plugin_view["rule"], view_func=plugin_view["view"].as_view( plugin_view_id, microscope=microscope_obj, plugin=plugin f"{plugin._name_python_safe}_{plugin_view_id}", microscope=microscope_obj, plugin=plugin, ), ) Loading
openflexure_microscope/plugins/loader.py +17 −2 Original line number Diff line number Diff line import importlib import copy import os import collections import inspect import logging Loading Loading @@ -258,9 +259,11 @@ class BasePlugin: # Expand the rule to include plugin name full_rule = "/{}/{}".format(self._name_uri_safe, cleaned_rule) # Create a Python-safe route ID view_id = cleaned_rule.replace("/", "_") # Create a Python-safe route ID logging.debug(view_id) # Store route information in a dictionary d = {"rule": full_rule, "view": view_class} Loading @@ -271,10 +274,22 @@ class BasePlugin: @property def gui(self): print(self._gui) # Handle missing/no GUI if not self._gui: return None # Handle GUI as a dictionary-returning callable function elif isinstance(self._gui, collections.Callable): api_gui = self._gui() # Handle GUI as a static dictionary elif isinstance(self._gui, dict): api_gui = copy.deepcopy(self._gui) # Handle borked GUI else: raise ValueError( "GUI must be a dictionary, or a dictionary-returning function with no arguments." ) api_gui["id"] = self._name if "forms" in api_gui and isinstance(api_gui["forms"], list): Loading