From 222c73261650201f5ce99e8dd4b1ce0d30a69eb4 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 2 Nov 2010 18:40:53 +0000 Subject: Fixed #10728 -- corrected subclassing of Fields who use the SubfieldBase metaclass. Thanks to G2P and George Sakkis for their work on the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14443 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/subclassing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/db/models/fields/subclassing.py b/django/db/models/fields/subclassing.py index 148a998f1c..759373e4d0 100644 --- a/django/db/models/fields/subclassing.py +++ b/django/db/models/fields/subclassing.py @@ -79,7 +79,8 @@ class SubfieldBase(LegacyConnection): def __new__(cls, base, name, attrs): new_class = super(SubfieldBase, cls).__new__(cls, base, name, attrs) new_class.contribute_to_class = make_contrib( - attrs.get('contribute_to_class')) + new_class, attrs.get('contribute_to_class') + ) return new_class class Creator(object): @@ -97,7 +98,7 @@ class Creator(object): def __set__(self, obj, value): obj.__dict__[self.field.name] = self.field.to_python(value) -def make_contrib(func=None): +def make_contrib(superclass, func=None): """ Returns a suitable contribute_to_class() method for the Field subclass. @@ -110,7 +111,7 @@ def make_contrib(func=None): if func: func(self, cls, name) else: - super(self.__class__, self).contribute_to_class(cls, name) + super(superclass, self).contribute_to_class(cls, name) setattr(cls, self.name, Creator(self)) return contribute_to_class -- cgit v1.3