'Return the model\'s attributes as a dictionary.
If include_extra_dict is True, \'extra\' attributes are literally
included in the resulting dictionary twice, for backwards-compatibility
with a broken implementation.'

def to_dict(self, include_extra_dict=False):

    if (not hasattr(self, 'extra')):
        raise AttributeError(self._msg)
    d = self.extra.copy()
    for attr in self.__class__.attributes:
        d[attr] = getattr(self, attr)
    if include_extra_dict:
        d['extra'] = self.extra.copy()
    return d
