33 data_dict_to_schema ,
44 function_signature_to_schema ,
55)
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+ )
714from . import View , ActionView , PropertyView
815from ..spec .utilities import compile_view_spec
916
@@ -19,6 +26,7 @@ def property_of(
1926 name : str = None ,
2027 readonly = False ,
2128 description = None ,
29+ semtype = None ,
2230 _legacy = False , # Old structure where POST is used to write property
2331):
2432
@@ -78,6 +86,9 @@ def _update(self, args):
7886 generated_class
7987 )
8088
89+ if semtype :
90+ generated_class = Semtype (semtype )(generated_class )
91+
8192 # Compile the generated views spec
8293 # Useful if its being attached to something other than a LabThing instance
8394 compile_view_spec (generated_class )
@@ -86,7 +97,12 @@ def _update(self, args):
8697
8798
8899def 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 ,
90106):
91107
92108 # Create a class name
@@ -112,6 +128,9 @@ def _post(self, args):
112128 generated_class
113129 )
114130
131+ if semtype :
132+ generated_class = Semtype (semtype )(generated_class )
133+
115134 if safe :
116135 generated_class = Safe (generated_class )
117136
0 commit comments