Improved property and action style

This commit is contained in:
Joel Collins 2020-01-08 18:43:07 +00:00
parent 3cbd0416d0
commit e44da64ed4
2 changed files with 14 additions and 10 deletions

View file

@ -6,7 +6,7 @@ from openflexure_microscope.common.flask_labthings.decorators import (
marshal_with, marshal_with,
doc, doc,
tag, tag,
ltaction, ThingAction,
doc_response, doc_response,
) )
@ -19,7 +19,7 @@ import logging
from flask import jsonify, request, abort, url_for, redirect, send_file from flask import jsonify, request, abort, url_for, redirect, send_file
@ltaction @ThingAction
class CaptureAPI(Resource): class CaptureAPI(Resource):
""" """
Create a new image capture. Create a new image capture.

View file

@ -71,17 +71,21 @@ def marshal_task(f):
return wrapper return wrapper
def ltaction(f): def ThingAction(viewcls):
# Pass params to call function attribute for external access # Pass params to call function attribute for external access
update_spec(f, {"tags": ["actions"]}) update_spec(viewcls, {"tags": ["actions"]})
update_spec(f, {"_groups": ["actions"]}) update_spec(viewcls, {"_groups": ["actions"]})
return f return viewcls
def ltproperty(f): thing_action = ThingAction
def ThingProperty(viewcls):
# Pass params to call function attribute for external access # Pass params to call function attribute for external access
update_spec(f, {"tags": ["properties"]}) update_spec(viewcls, {"tags": ["properties"]})
update_spec(f, {"_groups": ["properties"]}) update_spec(viewcls, {"_groups": ["properties"]})
return f return viewcls
thing_property = ThingProperty
class use_args(object): class use_args(object):
def __init__(self, schema, **kwargs): def __init__(self, schema, **kwargs):