Skip to content
Snippets Groups Projects
Commit 085e4400 authored by Christian Boettcher's avatar Christian Boettcher
Browse files

fix json encoding not automatically supported for custom classes

parent b009b2cf
Branches
Tags
1 merge request!1apiserver based on fastAPI
...@@ -12,6 +12,9 @@ class StoredData: ...@@ -12,6 +12,9 @@ class StoredData:
actualData: LocationData actualData: LocationData
users: List[str] users: List[str]
def toDict(self):
return {'actualData' : self.actualData.__dict__, 'users' : self.users}
# This stores LocationData via the StoredData Object as json files # This stores LocationData via the StoredData Object as json files
# These Jsonfiles then contain the actualData, as well as the users with permissions for this LocationData # These Jsonfiles then contain the actualData, as well as the users with permissions for this LocationData
...@@ -55,7 +58,7 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter): ...@@ -55,7 +58,7 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter):
toStore.users = [usr] toStore.users = [usr]
toStore.actualData = data toStore.actualData = data
with open(os.path.join(localpath, id), 'w') as json_file: with open(os.path.join(localpath, id), 'w') as json_file:
json.dump(toStore.__dict__, json_file) json.dump(toStore.toDict(), json_file)
return {id : data} return {id : data}
def getDetails(self, type: LocationDataType, id: str): def getDetails(self, type: LocationDataType, id: str):
...@@ -82,7 +85,7 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter): ...@@ -82,7 +85,7 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter):
toStore.actualData = data toStore.actualData = data
with open(fullpath, 'w') as file: with open(fullpath, 'w') as file:
json.dump(data.__dict__, file) json.dump(toStore.toDict(), file)
return {id : data} return {id : data}
def getOwner(self, type: LocationDataType, id: str): def getOwner(self, type: LocationDataType, id: str):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment