Renamed Resource to View, and allow custom root links

This commit is contained in:
Joel Collins 2020-01-14 11:41:56 +00:00
parent 234ebc1cbb
commit a329b9197b
18 changed files with 90 additions and 67 deletions

View file

@ -1,6 +1,6 @@
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
"""

View file

@ -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(),

View file

@ -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