Commit a329b919 authored by Joel Collins's avatar Joel Collins
Browse files

Renamed Resource to View, and allow custom root links

parent 234ebc1c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -79,16 +79,20 @@ for extension in find_extensions(USER_EXTENSIONS_PATH):

# Attach captures resources
labthing.add_view(views.CaptureList, f"/captures")
labthing.add_view(views.CaptureResource, f"/captures/<id>")
labthing.add_root_link(views.CaptureList, "captures")

labthing.add_view(views.CaptureView, f"/captures/<id>")
labthing.add_view(views.CaptureDownload, f"/captures/<id>/download/<filename>")
labthing.add_view(views.CaptureTags, f"/captures/<id>/tags")
labthing.add_view(views.CaptureMetadata, f"/captures/<id>/metadata")

# Attach settings and status resources
labthing.add_view(views.SettingsProperty, f"/settings")
labthing.add_root_link(views.SettingsProperty, "settings")
labthing.add_view(views.NestedSettingsProperty, "/settings/<path:route>")
labthing.add_view(views.StatusProperty, "/status")
labthing.add_view(views.NestedStatusProperty, "/status/<path:route>")
labthing.add_root_link(views.StatusProperty, "status")

# Attach streams resources
labthing.add_view(views.MjpegStream, f"/streams/mjpeg")
+4 −4
Original line number Diff line number Diff line
from openflexure_microscope.common.flask_labthings.find import find_component
from openflexure_microscope.common.flask_labthings.extensions import BaseExtension
from openflexure_microscope.common.flask_labthings.resource import Resource
from openflexure_microscope.common.flask_labthings.view import View
from openflexure_microscope.common.flask_labthings.decorators import (
    ThingAction,
    ThingProperty,
@@ -292,7 +292,7 @@ def fast_up_down_up_autofocus(
        return m.data_dict()


class MeasureSharpnessAPI(Resource):
class MeasureSharpnessAPI(View):
    def post(self):
        microscope = find_component("org.openflexure.microscope")

@@ -303,7 +303,7 @@ class MeasureSharpnessAPI(Resource):


@ThingAction
class AutofocusAPI(Resource):
class AutofocusAPI(View):
    """
    Run a standard autofocus
    """
@@ -330,7 +330,7 @@ class AutofocusAPI(Resource):


@ThingAction
class FastAutofocusAPI(Resource):
class FastAutofocusAPI(View):
    """
    Run a fast autofocus
    """
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ from openflexure_microscope.common.flask_labthings import fields

from openflexure_microscope.devel import taskify, abort, update_task_progress

from openflexure_microscope.common.flask_labthings.resource import Resource
from openflexure_microscope.common.flask_labthings.view import View
import time


@@ -341,7 +341,7 @@ def stack(


@ThingAction
class TileScanAPI(Resource):
class TileScanAPI(View):
    @use_args(
        {
            "filename": fields.String(),
+4 −4
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ import tempfile
import logging

from openflexure_microscope.common.flask_labthings.find import find_component
from openflexure_microscope.common.flask_labthings.resource import Resource
from openflexure_microscope.common.flask_labthings.view import View
from openflexure_microscope.common.flask_labthings.extensions import BaseExtension
from openflexure_microscope.common.flask_labthings.decorators import (
    ThingAction,
@@ -96,7 +96,7 @@ default_zip_manager = ZipManager()


@ThingAction
class ZipBuilderAPIView(Resource):
class ZipBuilderAPIView(View):
    def post(self):

        ids = list(JsonResponse(request).json)
@@ -109,12 +109,12 @@ class ZipBuilderAPIView(Resource):


@ThingProperty
class ZipListAPIView(Resource):
class ZipListAPIView(View):
    def get(self):
        return jsonify(default_zip_manager.session_zips)


class ZipGetterAPIView(Resource):
class ZipGetterAPIView(View):
    def get(self, session_id):
        if not session_id in default_zip_manager.session_zips:
            return abort(404)  # 404 Not Found
+3 −3
Original line number Diff line number Diff line
from openflexure_microscope.common.flask_labthings.resource import Resource
from openflexure_microscope.common.flask_labthings.view import View
from openflexure_microscope.common.flask_labthings.extensions import BaseExtension
from openflexure_microscope.common.flask_labthings.decorators import (
    ThingAction,
@@ -77,7 +77,7 @@ static_form = {


@ThingProperty
class TestAPIView(Resource):
class TestAPIView(View):
    def get(self):
        global val_int
        val_int += 1
@@ -85,7 +85,7 @@ class TestAPIView(Resource):


@ThingAction
class TestDoAPIView(Resource):
class TestDoAPIView(View):
    def post(self):
        global val_int
        val_int += 1
Loading