Commit 5139b24f authored by Joel Collins's avatar Joel Collins
Browse files

Updated to new LabThings structure

parent 304e6201
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ For example, if you are creating an API route, in which you expect parameters ``

.. code-block:: python

    from labthings.server.schema import Schema
    from labthings.server import fields
    from labthings.schema import Schema
    from labthings import fields

    class UserSchema(Schema):
        name = fields.String(required=True)
+4 −4
Original line number Diff line number Diff line
Basic extension structure
=========================

An extension starts as a simple instance of :py:class:`labthings.server.extensions.BaseExtension`. 
An extension starts as a simple instance of :py:class:`labthings.extensions.BaseExtension`. 
Each extension is described by a single ``BaseExtension`` instance, containing any number of methods, API views, and additional hardware components. 

In order to access the currently running microscope object, use the :py:func:`labthings.server.find.find_component` function, with the argument ``"org.openflexure.microscope"``. Likewise, any new components attached by other extensions can be found using their full name, as above.
In order to access the currently running microscope object, use the :py:func:`labthings.find_component` function, with the argument ``"org.openflexure.microscope"``. Likewise, any new components attached by other extensions can be found using their full name, as above.

A simple extension file, with no API views but application-available methods may look like:

@@ -15,7 +15,7 @@ Once this extension is loaded, any other extensions will have access to your met

.. code-block:: python

    from labthings.server.find import find_extension
    from labthings import find_extension

    def test_extension_method():
        # Find your extension. Returns None if it hasn't been found.
@@ -29,7 +29,7 @@ Once this extension is loaded, any other extensions will have access to your met
Subclassing ``BaseExtension``
-------------------------------

The syntax used above allows novice programmers to easily start building extensions, without having to deal with subclassing. However, for more complex extensions which require persistent state, subclassing :py:class:`labthings.server.extensions.BaseExtension` is recommended.
The syntax used above allows novice programmers to easily start building extensions, without having to deal with subclassing. However, for more complex extensions which require persistent state, subclassing :py:class:`labthings.extensions.BaseExtension` is recommended.

The same simple extension as seen above can be written using subclassing:

+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ An example of a long running task may look like:
.. code-block:: python

    ...
    from labthings.server.view import ActionView
    from labthings import ActionView

    class SlowAPI(ActionView):
        def post(self):
+2 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ class ZipObjectDescription:
    def close(self):
        logging.debug(self.fp.name)
        self.fp.close()
        if os.path.exists(self.fp.name):
            os.unlink(self.fp.name)

        assert not os.path.exists(self.fp.name)
+1 −1
Original line number Diff line number Diff line
{
  "name": "openflexure-microscope-jsclient",
  "version": "2.3.0",
  "version": "2.4.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
Loading