From 54106e845fa73fc2e247741387a5d98f76c4dae9 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 29 Jan 2019 14:49:04 +0000 Subject: [PATCH] Rearranged self.plugin documentation --- docs/source/plugins/hardware.rst | 12 ------------ docs/source/plugins/routes.rst | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/source/plugins/hardware.rst b/docs/source/plugins/hardware.rst index b76de0d3..1ac49a96 100644 --- a/docs/source/plugins/hardware.rst +++ b/docs/source/plugins/hardware.rst @@ -9,18 +9,6 @@ Introduction ------------ All instances of :py:class:`openflexure_microscope.api.v1.views.MicroscopeViewPlugin` must be attached via a microscope plugin. As a result of this, the ``MicroscopeViewPlugin`` class has a ``self.microscope`` attribute, allowing direct access to the :py:class:`openflexure_microscope.Microscope` object. This means that web API plugins can simply chain together basic microscope functions and expose new API routes. No additional microscope functionality is required. However, in most cases web API plugins will serve to provide API routes to new microscope functionality defined in a microscope plugin. -Because of this, instances of MicroscopeViewPlugin have direct access to their associated microscope plugin methods, without needing to know the plugin namespace in advance. As described earlier in this section, all plugins get attached to the microscope in their own namespace, based on the plugins name. This means there are two equivalent ways to access your plugin methods from a web API plugin: - -.. code-block:: python - - ... - # Call a method from our plugin, using the MicroscopeViewPlugin.plugin shortcut - self.plugin.my_plugin_method() - - # Call a method from our plugin, using the full route - self.microscope.my_plugin_name.my_plugin_method() - ... - Tasks and Locks --------------- diff --git a/docs/source/plugins/routes.rst b/docs/source/plugins/routes.rst index 0d951335..e5023675 100644 --- a/docs/source/plugins/routes.rst +++ b/docs/source/plugins/routes.rst @@ -65,6 +65,20 @@ For example: this_object = object_dictionary[object_id] ... +Calling plugin methods from routes +++++++++++++++++++++++++++++++++++ + +Instances of MicroscopeViewPlugin have direct access to their associated microscope plugin methods, without needing to know the plugin namespace in advance. As described earlier in this section, all plugins get attached to the microscope in their own namespace, based on the plugins name. This means there are two equivalent ways to access your plugin methods from a web API plugin: + +.. code-block:: python + + ... + # Call a method from our plugin, using the MicroscopeViewPlugin.plugin shortcut + self.plugin.my_plugin_method() + + # Call a method from our plugin, using the full route + self.microscope.my_plugin_name.my_plugin_method() + ... Building responses ++++++++++++++++++