3
3
data_dict_to_schema ,
4
4
function_signature_to_schema ,
5
5
)
6
- from labthings .server .decorators import PropertySchema , use_args , Doc , Safe , Idempotent
6
+ from labthings .server .decorators import (
7
+ PropertySchema ,
8
+ use_args ,
9
+ Doc ,
10
+ Safe ,
11
+ Idempotent ,
12
+ Semtype ,
13
+ )
7
14
from . import View , ActionView , PropertyView
8
15
from ..spec .utilities import compile_view_spec
9
16
@@ -19,6 +26,7 @@ def property_of(
19
26
name : str = None ,
20
27
readonly = False ,
21
28
description = None ,
29
+ semtype = None ,
22
30
_legacy = False , # Old structure where POST is used to write property
23
31
):
24
32
@@ -78,6 +86,9 @@ def _update(self, args):
78
86
generated_class
79
87
)
80
88
89
+ if semtype :
90
+ generated_class = Semtype (semtype )(generated_class )
91
+
81
92
# Compile the generated views spec
82
93
# Useful if its being attached to something other than a LabThing instance
83
94
compile_view_spec (generated_class )
@@ -86,7 +97,12 @@ def _update(self, args):
86
97
87
98
88
99
def action_from (
89
- function , name : str = None , description = None , safe = False , idempotent = False ,
100
+ function ,
101
+ name : str = None ,
102
+ description = None ,
103
+ safe = False ,
104
+ idempotent = False ,
105
+ semtype = None ,
90
106
):
91
107
92
108
# Create a class name
@@ -112,6 +128,9 @@ def _post(self, args):
112
128
generated_class
113
129
)
114
130
131
+ if semtype :
132
+ generated_class = Semtype (semtype )(generated_class )
133
+
115
134
if safe :
116
135
generated_class = Safe (generated_class )
117
136
0 commit comments