mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Fixes bug in serializing dataclasses in place
This commit is contained in:
parent
cbf5479253
commit
8bb20730fc
1 changed files with 4 additions and 5 deletions
|
@ -162,15 +162,14 @@ class ActivityObject:
|
|||
|
||||
def serialize(self):
|
||||
''' convert to dictionary with context attr '''
|
||||
data = self.__dict__
|
||||
data = self.__dict__.copy()
|
||||
# recursively serialize
|
||||
for (k, v) in data.items():
|
||||
try:
|
||||
is_subclass = issubclass(type(v), ActivityObject)
|
||||
except TypeError:
|
||||
is_subclass = False
|
||||
if is_subclass:
|
||||
if issubclass(type(v), ActivityObject):
|
||||
data[k] = v.serialize()
|
||||
except TypeError:
|
||||
pass
|
||||
data = {k:v for (k, v) in data.items() if v is not None}
|
||||
data['@context'] = 'https://www.w3.org/ns/activitystreams'
|
||||
return data
|
||||
|
|
Loading…
Reference in a new issue