from sqlalchemy.inspection import inspect
from zou.app.utils.fields import serialize_value


class SerializerMixin(object):

    def serialize(self):
        attrs = inspect(self).attrs.keys()
        return {
            attr: serialize_value(getattr(self, attr)) for attr in attrs
        }

    @staticmethod
    def serialize_list(models):
        return [model.serialize() for model in models]

from sqlalchemy.inspection import inspect
from zou.app.utils.fields import serialize_value


class SerializerMixin(object):

    def serialize(self, obj_type=None):
        attrs = inspect(self).attrs.keys()
        obj_dict = {
            attr: serialize_value(getattr(self, attr)) for attr in attrs
        }
        obj_dict["type"] = obj_type or type(self).__name__
        return obj_dict

    @staticmethod
    def serialize_list(models, obj_type=None):
        return [model.serialize(obj_type=obj_type) for model in models]

Add object type to dict serialization
Add object type to dict serialization
