Skip to content

Commit 4c7cef4

Browse files
committed
Patched up property responses that are a generator (needs proper fix)
1 parent 2d9f9ce commit 4c7cef4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/labthings/server/view/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_value(self):
4141
raise TypeError("Attribute 'get' of View must be a callable")
4242
response = get_method() # pylint: disable=not-callable
4343
if isinstance(response, ResponseBase): # Pluck useful data out of HTTP response
44-
return response.json if response.json else response.data.decode()
44+
return response.json if response.json else response.data
4545
else: # Unless somehow an HTTP response isn't returned...
4646
return response
4747

@@ -113,6 +113,10 @@ class PropertyView(View):
113113
__apispec__ = {"tags": {"properties"}}
114114

115115
def dispatch_request(self, *args, **kwargs):
116+
if request.method == "GET":
117+
return View.dispatch_request(self, *args, **kwargs)
118+
119+
# FIXME: Sketchy as this breaks if the response is a generator/loop
116120
resp = View.dispatch_request(self, *args, **kwargs)
117121

118122
property_value = self.get_value()

0 commit comments

Comments
 (0)