Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

magic-removal: Renamed Manager.klass to Manager.model

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2193 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 836478fa74eb0a16e8aefa2cdd076990707d2b2e 1 parent a917054
@adrianholovaty adrianholovaty authored
Showing with 13 additions and 13 deletions.
  1. +3 −3 django/db/models/fields/related.py
  2. +10 −10 django/db/models/manager.py
View
6 django/db/models/fields/related.py
@@ -121,10 +121,10 @@ def __get__(self, instance, instance_type=None):
# Prepare the manager.
# TODO: Fix this hack?
- # We're setting self.manager.klass here because
- # self.manager._prepare() expects that self.manager.klass is
+ # We're setting self.manager.model here because
+ # self.manager._prepare() expects that self.manager.model is
# set. This is slightly hackish.
- manager.klass = self.related.model
+ manager.model = self.related.model
manager._prepare()
return manager
View
20 django/db/models/manager.py
@@ -34,28 +34,28 @@ def __init__(self):
# Increase the creation counter, and save our local copy.
self.creation_counter = Manager.creation_counter
Manager.creation_counter += 1
- self.klass = None
+ self.model = None
def _prepare(self):
- if self.klass._meta.get_latest_by:
+ if self.model._meta.get_latest_by:
self.get_latest = self.__get_latest
- def contribute_to_class(self, klass, name):
+ def contribute_to_class(self, model, name):
# TODO: Use weakref because of possible memory leak / circular reference.
- self.klass = klass
- dispatcher.connect(self._prepare, signal=signals.class_prepared, sender=klass)
- setattr(klass, name, ManagerDescriptor(self))
- if not hasattr(klass, '_default_manager') or self.creation_counter < klass._default_manager.creation_counter:
- klass._default_manager = self
+ self.model = model
+ dispatcher.connect(self._prepare, signal=signals.class_prepared, sender=model)
+ setattr(model, name, ManagerDescriptor(self))
+ if not hasattr(model, '_default_manager') or self.creation_counter < model._default_manager.creation_counter:
+ model._default_manager = self
def __get_latest(self, *args, **kwargs):
- kwargs['order_by'] = ('-' + self.klass._meta.get_latest_by,)
+ kwargs['order_by'] = ('-' + self.model._meta.get_latest_by,)
kwargs['limit'] = 1
return self.get_object(*args, **kwargs)
def add(self, **kwargs):
kwargs.update(self.core_values)
- new_obj = self.klass(**kwargs)
+ new_obj = self.model(**kwargs)
new_obj.save()
return new_obj
add.alters_data = True

0 comments on commit 836478f

Please sign in to comment.
Something went wrong with that request. Please try again.