I have a module called db, which looks like this (shortened):# A dictionary that maps type names (as returned by Model._get_type()) to classes.TYPE_REGISTRY = {}class Model(object):    A superclass to be used for database models.       To specify which attributes should be savied add an 'attributes' class property       containing a list of property names. The first property name should be the primary key.    def __init__(self, **kwargs):         for name in kwargs:            setattr(self, name, kwargs[name])    @classmethod    def get_connection(cls):        returns a database connection        return get_connection()    @classmethod    def get_attributes(cls):        Get a list of all attributes that an instance of this model can have.        attrs = []        for sup in cls.__mro__:            if hasattr(sup, attributes):                attrs = attrs + sup.attributes        return list(set(attrs))    @classmethod    def register(cls):        Registers a model's type.        TYPE_REGISTRY[cls._get_type()] = cls    def to_dict(self):        Turn this object into a dicionary that can be saved to the database.                d = {__type: self._get_type()}        for attr in self.get_attributes():            if not hasattr(self, attr):                continue            d[attr] = getattr(self, attr)        d = self.prepare_value(d)        return d    @classmethod    def prepare_value(cls, value):        Ensures that a value can be written to the database.        if isinstance(value, datetime):            return value.replace(tzinfo=r.make_timezone(+00:00))        if hasattr(value, to_dict):            value = value.to_dict()        if isinstance(value, dict):            return cls._prepare_dict(value)        if isinstance(value, (set, tuple, list)):            return [cls.prepare_value(item) for item in value]        elif not isinstance(value, (basestring, int, float, long, bool)) and value is not None:            raise ValueError(Values must either implement to_dict, or be of                             type dict, set, tuple, list, basestring, int,                              float, long, datetime or None, got %s: %s % (type(value), value))        return value    @classmethod    def _prepare_dict(cls, d):        Given a dictionary, this method ensures that it is ready to be written to the database.        result = {}        for key in d:            result[key] = cls.prepare_value(d[key])        return result    @classmethod    def from_dict(cls, d):        Converts a dictionary back to the class within the application        if not d:            return None        type_ = d.get(__type)        del d[__type]        if type_:            clss = TYPE_REGISTRY[type_]        else:            clss = cls        for key in d:            if isinstance(d[key], datetime):                d[key] = d[key].replace(tzinfo=None)            if isinstance(d[key], dict) and __type in d[key]:                d[key] = cls.from_dict(d[key])            if isinstance(d[key], list):                for i in xrange(len(d[key])):                    if isinstance(d[key][i], dict) and __type in d[key][i]:                        d[key][i] = cls.from_dict(d[key][i])        return clss(**d)    @classmethod    def _get_type(cls):        return cls.__name__.lower() + s    @classmethod    def get_table(cls):        Get the table object for this class.        default_name = cls._get_type()        table_name = getattr(cls, table_name, default_name)        return r.table(table_name)    @classmethod    def run(cls, query):        Runs the given query        return query.run(cls.get_connection())    @classmethod    def get(cls, id):        Get an object by its id.        return cls.from_dict(cls.run(cls.get_table().get(id)))    @property    def table(self):        return self.get_table()This works nicely in most kinds of queries, but when I use .pluck(), I find myself having to include __type in the list of attributes I want to pluck, so that I can use .from_dict(d) with the result, and I'd somehow like that key to always be included.Would there be a good way to abstract this out?Here's an example query I'd like to be able to make:class Post(db.Model):    attributes = [title, author, published, content, image]    @classmethod    def get_by_author(cls, author, fields):        return cls.from_dict(            cls.run(cls.get_table().get_all(author, index=author)).pluck(*fields)        )Currently, I'd have to make sure that fields includes __type. That's easy enough to do, but it's a massive abstraction leak.
Abstracting away implementation details of my rethinkdb Model class
python