"""{{ mixedName }}.py - Module containing the {{ mixedName }} class"""
import uuid
import datetime
from sqlalchemy import Boolean, Column, ForeignKey, DateTime, JSON, String, text
from sqlalchemy.dialects.mysql import BINARY
{% if relationships|length > 0 %}from sqlalchemy.orm import relationship{% endif %}

from .base import Base

class {{ genprefix}}{{ mixedName }}(Base):
    """Data model object representing a {{ mixedName }}"""
    __tablename__ = '{{ mixedName }}'
    __uuid_list__ = {{ uuid_set }}
    __primary_key__ = '{{ name_id }}'
    {% for dmField in dmFields %}{{ dmField }}
    {% endfor %}
    {% for rel in relationships %}{{ rel.name }} = relationship('{{ rel.table }}', back_populates='{{ rel.field }}')
    {% endfor %}
{% if idCount == 1 %}
    def __init__(self, **kwargs):
        """Initializes the ID for newly constructed objects"""
        super({{ genprefix}}{{ mixedName }}, self).__init__(**kwargs)
        self.{{ name_id }} = uuid.uuid4().bytes
{% endif %}

    def dump(self, deep=False):
        """Returns dictionary of fields and values"""
        ret = {}
        for key, value in vars(self).items():
            if key in self.__uuid_list__:
                ret[key] = str(uuid.UUID(bytes=value))
            elif not key.startswith('_'):
                ret[key] = value
        return ret
