From 30addc12b4e5d8195da4692364094dfd40928e9a Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Sun, 14 Sep 2014 16:47:21 +0200 Subject: [PATCH] Do not use abstract base class instance We want to move common code into the base class with out changing the behaviour of the default type. --- beets/dbcore/db.py | 4 ++-- beets/dbcore/types.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 307f044f9..b2d2df360 100644 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -24,8 +24,8 @@ import collections import beets from beets.util.functemplate import Template +from beets.dbcore import types from .query import MatchQuery, NullSort -from .types import BASE_TYPE class FormattedMapping(collections.Mapping): @@ -199,7 +199,7 @@ class Model(object): If the field has no explicit type, it is given the base `Type`, which does no conversion. """ - return self._fields.get(key) or self._types.get(key) or BASE_TYPE + return self._fields.get(key) or self._types.get(key) or types.DEFAULT def __getitem__(self, key): """Get the value for a field. Raise a KeyError if the field is diff --git a/beets/dbcore/types.py b/beets/dbcore/types.py index 2738f3425..f96863f9c 100644 --- a/beets/dbcore/types.py +++ b/beets/dbcore/types.py @@ -84,6 +84,10 @@ class Type(object): # Reusable types. +class Default(Type): + pass + + class Integer(Type): """A basic integer type. """ @@ -187,7 +191,7 @@ class Boolean(Type): # Shared instances of common types. -BASE_TYPE = Type() +DEFAULT = Default() INTEGER = Integer() PRIMARY_ID = Id(True) FOREIGN_ID = Id(False)