Skip to content

Commit

Permalink
Fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Aug 21, 2020
1 parent 4a5cb86 commit 47b7b09
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions labthings_client/affordances.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ def set(self, *args, **kwargs):
return self.put(*args, **kwargs)

def put(self, value):
if value is None:
value = {}
if not self.read_only:
r = requests.put(self.self_url, json=value or {})
r = requests.put(self.self_url, json=value)
r.raise_for_status()
return r.json()
else:
raise AttributeError("Can't set attribute, is read-only")

def post(self, value):
if value is None:
value = {}
if not self.read_only:
r = requests.post(self.self_url, json=value or {})
r = requests.post(self.self_url, json=value)
r.raise_for_status()
return r.json()
else:
Expand Down

0 comments on commit 47b7b09

Please sign in to comment.