Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit e7e77b8

Browse files
committed
Allow special load and dump functions independently.
1 parent d293cd1 commit e7e77b8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/oidcmsg/impexp.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ def dump(self, exclude_attributes: Optional[List[str]] = None) -> dict:
4747

4848
info[attr] = self.dump_attr(cls, item, exclude_attributes)
4949

50-
for attr, d in self.special_load_dump.items():
50+
for attr, func in self.special_load_dump.items():
5151
item = getattr(self, attr, None)
5252
if item:
53-
info[attr] = d["dump"](item, exclude_attributes=exclude_attributes)
53+
if "dump" in func:
54+
info[attr] = func["dump"](item, exclude_attributes=exclude_attributes)
55+
else:
56+
cls = self.parameter[attr]
57+
info[attr] = self.dump_attr(cls, item, exclude_attributes)
5458

5559
return info
5660

@@ -127,7 +131,11 @@ def load(self, item: dict, init_args: Optional[dict] = None, load_args: Optional
127131

128132
for attr, func in self.special_load_dump.items():
129133
if attr in item:
130-
setattr(self, attr, func["load"](item[attr], **_kwargs))
134+
if "load" in func:
135+
setattr(self, attr, func["load"](item[attr], **_kwargs))
136+
else:
137+
cls = self.parameter[attr]
138+
setattr(self, attr, self.load_attr(cls, item[attr], **_kwargs))
131139

132140
self.local_load_adjustments(**_load_args)
133141
return self

0 commit comments

Comments
 (0)