|
|
@ -77,7 +77,7 @@ def register_transformer( |
|
|
|
if model_name not in _model_transformers: |
|
|
|
_model_transformers[model_name] = model_serializer |
|
|
|
else: |
|
|
|
raise ValueError( |
|
|
|
raise KeyError( |
|
|
|
' '.join([ |
|
|
|
'A transformer for type "{}" already exists with class "{}".', |
|
|
|
'Cannot register a new transformer with class "{}"' |
|
|
@ -100,12 +100,12 @@ def serialize_model(model_obj: db.Model, |
|
|
|
|
|
|
|
|
|
|
|
def deserialize_model( |
|
|
|
model_type: str, |
|
|
|
model_type: Type[db.Model], |
|
|
|
json_model_object: dict, |
|
|
|
options: Optional[List[str]] = None) -> db.Model: |
|
|
|
"""Lookup a Model and hand it off to the deserializer.""" |
|
|
|
try: |
|
|
|
transformer = _model_transformers[model_type] |
|
|
|
transformer = _model_transformers[model_type.__name__] |
|
|
|
return transformer( |
|
|
|
transformer.type()).deserialize(json_model_object, options) |
|
|
|
except KeyError: |
|
|
|