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.
This commit is contained in:
Thomas Scholtes 2014-09-14 16:47:21 +02:00
parent 629fc0087d
commit 30addc12b4
2 changed files with 7 additions and 3 deletions

View file

@ -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

View file

@ -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)