8
8
9
9
from ..actions .pool import Pool
10
10
from ..deque import Deque
11
- from ..find import current_labthing
11
+ from ..find import current_labthing , find_extension
12
12
from ..marshalling import marshal_with , use_args
13
13
from ..representations import DEFAULT_REPRESENTATIONS
14
14
from ..schema import ActionSchema , EventSchema , Schema , build_action_schema
@@ -40,6 +40,11 @@ class View(MethodView):
40
40
_cls_tags : Set [str ] = set () # Class tags that shouldn't be removed
41
41
_opmap : Dict [str , str ] = {} # Mapping of Thing Description ops to class methods
42
42
43
+ # Name of parent extension, if one exists.
44
+ # This is only used for extension development where Views are added to the extension.
45
+ # We store the name instead of the object itself to prevent circular references.
46
+ _parent_extension_name : Optional [str ] = None
47
+
43
48
def __init__ (self , * args , ** kwargs ):
44
49
MethodView .__init__ (self , * args , ** kwargs )
45
50
@@ -50,6 +55,12 @@ def __init__(self, *args, **kwargs):
50
55
else DEFAULT_REPRESENTATIONS
51
56
)
52
57
58
+ @property
59
+ def extension (self ):
60
+ if self ._parent_extension_name :
61
+ return find_extension (self ._parent_extension_name )
62
+ return None
63
+
53
64
@classmethod
54
65
def get_tags (cls ):
55
66
""" """
@@ -257,7 +268,7 @@ class EventView(View):
257
268
258
269
# Internal
259
270
_opmap = {
260
- "subscribeevent" : "get" ,
271
+ "subscribeevent" : "get"
261
272
} # Mapping of Thing Description ops to class methods
262
273
_cls_tags = {"events" }
263
274
_deque = Deque () # Action queue
0 commit comments