Switched to ActionView and PropertyView from decorators
This commit is contained in:
parent
677b08d509
commit
1819ca6a9c
18 changed files with 57 additions and 98 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, PropertyView
|
||||
|
||||
from labthings.server.decorators import (
|
||||
use_args,
|
||||
|
|
@ -36,8 +36,7 @@ def rename(microscope, new_name):
|
|||
## Extension views
|
||||
|
||||
# Since we only have a GET method here, it'll register as a read-only property
|
||||
@ThingProperty
|
||||
class ExampleIdentifyView(View):
|
||||
class ExampleIdentifyView(PropertyView):
|
||||
# Format our returned object using MicroscopeIdentifySchema
|
||||
@marshal_with(MicroscopeIdentifySchema())
|
||||
def get(self):
|
||||
|
|
@ -52,11 +51,10 @@ class ExampleIdentifyView(View):
|
|||
return microscope
|
||||
|
||||
|
||||
@ThingProperty
|
||||
# We can use a single schema for all methods if the input and output will be formatted identically
|
||||
# Eg. Here, we will always expect a "name" string argument, and always return a "name" string attribute
|
||||
@PropertySchema({"name": fields.String(required=True, example="My Example Microscope")})
|
||||
class ExampleRenameView(View):
|
||||
class ExampleRenameView(PropertyView):
|
||||
def get(self):
|
||||
"""
|
||||
Show the current microscope name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue