diff options
| author | Tim Graham <timograham@gmail.com> | 2015-08-12 09:26:57 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-23 19:31:09 -0400 |
| commit | 08ab262649fc483df71d860d217a864ecbbcc69d (patch) | |
| tree | 9315a1de8d5d56ea1be416b491e44976a150c30f /django | |
| parent | 4fd264b6f1737b0317fdd95b3d7ff3bba15ae6c3 (diff) | |
Removed SubfieldBase per deprecation timeline.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/__init__.py | 1 | ||||
| -rw-r--r-- | django/db/models/fields/subclassing.py | 63 |
2 files changed, 0 insertions, 64 deletions
diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index 5d9e14ab46..af497424fa 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -12,7 +12,6 @@ from django.db.models.expressions import ( # NOQA from django.db.models.fields import * # NOQA from django.db.models.fields.files import FileField, ImageField # NOQA from django.db.models.fields.proxy import OrderWrt # NOQA -from django.db.models.fields.subclassing import SubfieldBase # NOQA from django.db.models.lookups import Lookup, Transform # NOQA from django.db.models.manager import Manager # NOQA from django.db.models.query import Q, Prefetch, QuerySet # NOQA diff --git a/django/db/models/fields/subclassing.py b/django/db/models/fields/subclassing.py deleted file mode 100644 index 84d13ce85c..0000000000 --- a/django/db/models/fields/subclassing.py +++ /dev/null @@ -1,63 +0,0 @@ -""" -Convenience routines for creating non-trivial Field subclasses, as well as -backwards compatibility utilities. - -Add SubfieldBase as the metaclass for your Field subclass, implement -to_python() and the other necessary methods and everything will work -seamlessly. -""" - -import warnings - -from django.utils.deprecation import RemovedInDjango110Warning - - -class SubfieldBase(type): - """ - A metaclass for custom Field subclasses. This ensures the model's attribute - has the descriptor protocol attached to it. - """ - def __new__(cls, name, bases, attrs): - warnings.warn("SubfieldBase has been deprecated. Use Field.from_db_value instead.", - RemovedInDjango110Warning) - - new_class = super(SubfieldBase, cls).__new__(cls, name, bases, attrs) - new_class.contribute_to_class = make_contrib( - new_class, attrs.get('contribute_to_class') - ) - return new_class - - -class Creator(object): - """ - A placeholder class that provides a way to set the attribute on the model. - """ - def __init__(self, field): - self.field = field - - def __get__(self, obj, type=None): - if obj is None: - return self - return obj.__dict__[self.field.name] - - def __set__(self, obj, value): - obj.__dict__[self.field.name] = self.field.to_python(value) - - -def make_contrib(superclass, func=None): - """ - Returns a suitable contribute_to_class() method for the Field subclass. - - If 'func' is passed in, it is the existing contribute_to_class() method on - the subclass and it is called before anything else. It is assumed in this - case that the existing contribute_to_class() calls all the necessary - superclass methods. - """ - def contribute_to_class(self, cls, name, **kwargs): - if func: - func(self, cls, name, **kwargs) - else: - super(superclass, self).contribute_to_class(cls, name, **kwargs) - setattr(cls, self.name, Creator(self)) - - return contribute_to_class |
