Entity should use Message.Encoder as a JSON serializer.

This commit is contained in:
Fabio Manganiello 2023-04-02 02:44:19 +02:00
parent 31f411868c
commit 3cd42c9e45
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -22,7 +22,7 @@ from sqlalchemy import (
from sqlalchemy.orm import ColumnProperty, Mapped, backref, relationship from sqlalchemy.orm import ColumnProperty, Mapped, backref, relationship
from platypush.common.db import Base from platypush.common.db import Base
from platypush.message import JSONAble from platypush.message import JSONAble, Message
EntityRegistryType = Dict[str, Type['Entity']] EntityRegistryType = Dict[str, Type['Entity']]
entities_registry: EntityRegistryType = {} entities_registry: EntityRegistryType = {}
@ -183,7 +183,7 @@ if 'entity' not in Base.metadata:
""" """
:return: A JSON-encoded representation of the entity. :return: A JSON-encoded representation of the entity.
""" """
return json.dumps(self.to_dict()) return json.dumps(self.to_dict(), cls=Message.Encoder)
def __setattr__(self, key, value): def __setattr__(self, key, value):
""" """