From bcc15e2b21217c280afd613b1beff238e23fce75 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 21 Mar 2014 07:45:38 -0400 Subject: [PATCH] Removed backward compatible shims to rename get_query_set and similar queryset methods. Also removed the backward compatible shims introduced to rename the attributes ChangeList.root_query_set and ChangeList.query_set. --- django/contrib/admin/options.py | 11 ++--------- django/contrib/admin/views/main.py | 24 ++---------------------- django/contrib/contenttypes/fields.py | 10 +--------- django/db/models/fields/related.py | 12 ++---------- django/db/models/manager.py | 10 +--------- 5 files changed, 8 insertions(+), 59 deletions(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index c67c7dc7c8..1050a0d591 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -36,8 +36,7 @@ from django.shortcuts import get_object_or_404 from django.template.response import SimpleTemplateResponse, TemplateResponse from django.utils import six from django.utils.decorators import method_decorator -from django.utils.deprecation import (RenameMethodsBase, - RemovedInDjango18Warning, RemovedInDjango19Warning) +from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import escape, escapejs from django.utils.http import urlencode @@ -92,13 +91,7 @@ FORMFIELD_FOR_DBFIELD_DEFAULTS = { csrf_protect_m = method_decorator(csrf_protect) -class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase): - renamed_methods = ( - ('queryset', 'get_queryset', RemovedInDjango18Warning), - ) - - -class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): +class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)): """Functionality common to both ModelAdmin and InlineAdmin.""" raw_id_fields = () diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 15f5c57206..4433a7ec2a 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse from django.db import models from django.db.models.fields import FieldDoesNotExist from django.utils import six -from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning +from django.utils.deprecation import RemovedInDjango18Warning from django.utils.encoding import force_text from django.utils.translation import ugettext, ugettext_lazy from django.utils.http import urlencode @@ -57,13 +57,7 @@ def _is_changelist_popup(request): return False -class RenameChangeListMethods(RenameMethodsBase): - renamed_methods = ( - ('get_query_set', 'get_queryset', RemovedInDjango18Warning), - ) - - -class ChangeList(six.with_metaclass(RenameChangeListMethods)): +class ChangeList(object): def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, list_max_show_all, list_editable, model_admin): @@ -110,20 +104,6 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)): self.title = title % force_text(self.opts.verbose_name) self.pk_attname = self.lookup_opts.pk.attname - @property - def root_query_set(self): - warnings.warn("`ChangeList.root_query_set` is deprecated, " - "use `root_queryset` instead.", - RemovedInDjango18Warning, 2) - return self.root_queryset - - @property - def query_set(self): - warnings.warn("`ChangeList.query_set` is deprecated, " - "use `queryset` instead.", - RemovedInDjango18Warning, 2) - return self.queryset - def get_filters_params(self, params=None): """ Returns all params except IGNORED_PARAMS diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index 7c27d5960b..afb6105a22 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -12,19 +12,11 @@ from django.db.models.fields.related import ForeignObject, ForeignObjectRel from django.db.models.related import PathInfo from django.db.models.sql.datastructures import Col from django.contrib.contenttypes.models import ContentType -from django.utils import six -from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.encoding import smart_text, python_2_unicode_compatible -class RenameGenericForeignKeyMethods(RenameMethodsBase): - renamed_methods = ( - ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning), - ) - - @python_2_unicode_compatible -class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)): +class GenericForeignKey(object): """ Provides a generic relation to any object through content-type/object-id fields. diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 2443bbf5c8..148b979ad3 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -14,7 +14,6 @@ from django.db.models.query import QuerySet from django.db.models.sql.datastructures import Col from django.utils.encoding import smart_text from django.utils import six -from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.translation import ugettext_lazy as _ from django.utils.functional import curry, cached_property from django.core import exceptions @@ -344,14 +343,7 @@ class RelatedField(Field): return self.rel.related_query_name or self.rel.related_name or self.opts.model_name -class RenameRelatedObjectDescriptorMethods(RenameMethodsBase): - renamed_methods = ( - ('get_query_set', 'get_queryset', RemovedInDjango18Warning), - ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning), - ) - - -class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescriptorMethods)): +class SingleRelatedObjectDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # a single "remote" value, on the class pointed to by a related field. @@ -479,7 +471,7 @@ class SingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescri setattr(value, self.related.field.get_cache_name(), instance) -class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjectDescriptorMethods)): +class ReverseSingleRelatedObjectDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # a single "remote" value, on the class that defines the related field. diff --git a/django/db/models/manager.py b/django/db/models/manager.py index 4f28253de9..2e4f15f892 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -6,7 +6,6 @@ from django.db.models.query import QuerySet from django.db.models import signals from django.db.models.fields import FieldDoesNotExist from django.utils import six -from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning from django.utils.encoding import python_2_unicode_compatible @@ -52,15 +51,8 @@ def ensure_default_manager(sender, **kwargs): signals.class_prepared.connect(ensure_default_manager) -class RenameManagerMethods(RenameMethodsBase): - renamed_methods = ( - ('get_query_set', 'get_queryset', RemovedInDjango18Warning), - ('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning), - ) - - @python_2_unicode_compatible -class BaseManager(six.with_metaclass(RenameManagerMethods)): +class BaseManager(object): # Tracks each time a Manager instance is created. Used to retain order. creation_counter = 0