@@ -51,29 +51,32 @@ def __init__(
51
51
types : list = None ,
52
52
version : str = "0.0.0" ,
53
53
format_flask_exceptions : bool = True ,
54
+ json_encoder = LabThingsJSONEncoder ,
54
55
):
55
56
if types is None :
56
57
types = []
57
58
self .app = app # Becomes a Flask app
58
59
self .sockets = None # Becomes a Socket(app) websocket handler
59
60
60
- self .components = {}
61
+ self .components = (
62
+ {}
63
+ ) # Dictionary of attached component objects, available to extensions
61
64
62
- self .extensions = {}
65
+ self .extensions = {} # Dictionary of LabThings extension objects
63
66
64
67
self .actions = Pool () # Pool of threads for Actions
65
68
66
- self .events = {}
69
+ self .events = {} # Dictionary of Event affordances
67
70
68
- self .views = []
69
- self ._property_views = {}
70
- self ._action_views = {}
71
+ self .views = [] # List of View classes
72
+ self ._property_views = {} # Dictionary of PropertyView views
73
+ self ._action_views = {} # Dictionary of ActionView views
71
74
72
- self .subscribers = set ()
75
+ self .subscribers = set () # Set of connected event subscribers
73
76
74
- self .endpoints = set ()
77
+ self .endpoints = set () # Set of endpoint strings
75
78
76
- self .url_prefix = prefix
79
+ self .url_prefix = prefix # Global URL prefix for all LabThings views
77
80
78
81
for t in types :
79
82
if ";" in t :
@@ -97,7 +100,7 @@ def __init__(
97
100
# Representation formatter map
98
101
self .representations = DEFAULT_REPRESENTATIONS
99
102
100
- # API Spec
103
+ # OpenAPI spec for Swagger docs
101
104
self .spec = APISpec (
102
105
title = self .title ,
103
106
version = self .version ,
@@ -108,6 +111,9 @@ def __init__(
108
111
# Thing description
109
112
self .thing_description = ThingDescription ()
110
113
114
+ # JSON encoder class
115
+ self .json_encoder = json_encoder
116
+
111
117
if app is not None :
112
118
self .init_app (app )
113
119
@@ -162,7 +168,7 @@ def init_app(self, app):
162
168
error_handler .init_app (app )
163
169
164
170
# Custom JSON encoder
165
- app .json_encoder = LabThingsJSONEncoder
171
+ app .json_encoder = self . json_encoder
166
172
167
173
# Add resources, if registered before tying to a Flask app
168
174
if len (self .views ) > 0 :
0 commit comments