magic-removal: removed circular reference from options to model class
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1748 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5eddd9612d
commit
050351c339
|
@ -20,6 +20,7 @@ if not hasattr(__builtins__, 'set'):
|
|||
from sets import Set as set
|
||||
|
||||
attribute_transforms = {}
|
||||
|
||||
class ModelBase(type):
|
||||
"Metaclass for all models"
|
||||
def __new__(cls, name, bases, attrs):
|
||||
|
@ -119,7 +120,7 @@ class Model(object):
|
|||
def _prepare(cls):
|
||||
# Creates some methods once self._meta has been populated.
|
||||
opts = cls._meta
|
||||
opts._prepare()
|
||||
opts._prepare(cls)
|
||||
|
||||
if opts.order_with_respect_to:
|
||||
cls.get_next_in_order = curry(cls._get_next_or_previous_in_order, is_next=True)
|
||||
|
|
|
@ -45,8 +45,6 @@ class Options:
|
|||
raise TypeError, "'class META' got invalid attribute(s): %s" % ','.join(meta_attrs.keys())
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
# TODO: Remove this self.model reference. This is a circular reference.
|
||||
self.model = cls
|
||||
cls._meta = self
|
||||
self.object_name = cls.__name__
|
||||
self.module_name = get_module_name(self.object_name )
|
||||
|
@ -58,7 +56,7 @@ class Options:
|
|||
self.merge_meta()
|
||||
del self.meta
|
||||
|
||||
def _prepare(self):
|
||||
def _prepare(self, model):
|
||||
if self.order_with_respect_to:
|
||||
self.order_with_respect_to = self.get_field(self.order_with_respect_to)
|
||||
self.ordering = ('_order',)
|
||||
|
@ -82,7 +80,7 @@ class Options:
|
|||
if self.pk is None:
|
||||
auto = AutoField(verbose_name='ID', primary_key=True)
|
||||
auto.creation_counter = -1
|
||||
self.model.add_to_class('id', auto)
|
||||
model.add_to_class('id', auto)
|
||||
self.pk = self.fields[0]
|
||||
# Cache whether this has an AutoField.
|
||||
self.has_auto_field = False
|
||||
|
|
Loading…
Reference in New Issue