Skip to content

Commit

Permalink
Fixed #14436 -- Escalated 1.2 PendingDeprecationWarnings to Deprecati…
Browse files Browse the repository at this point in the history
…onWarnings, and removed 1.1 deprecated code.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14138 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Oct 11, 2010
1 parent 5e5be2c commit 1070c57
Show file tree
Hide file tree
Showing 36 changed files with 97 additions and 145 deletions.
75 changes: 0 additions & 75 deletions django/contrib/admin/sites.py
Expand Up @@ -456,81 +456,6 @@ def app_index(self, request, app_label, extra_context=None):
context_instance=context_instance
)

def root(self, request, url):
"""
DEPRECATED. This function is the old way of handling URL resolution, and
is deprecated in favor of real URL resolution -- see ``get_urls()``.
This function still exists for backwards-compatibility; it will be
removed in Django 1.3.
"""
import warnings
warnings.warn(
"AdminSite.root() is deprecated; use include(admin.site.urls) instead.",
DeprecationWarning
)

#
# Again, remember that the following only exists for
# backwards-compatibility. Any new URLs, changes to existing URLs, or
# whatever need to be done up in get_urls(), above!
#

if request.method == 'GET' and not request.path.endswith('/'):
return http.HttpResponseRedirect(request.path + '/')

if settings.DEBUG:
self.check_dependencies()

# Figure out the admin base URL path and stash it for later use
self.root_path = re.sub(re.escape(url) + '$', '', request.path)

url = url.rstrip('/') # Trim trailing slash, if it exists.

# The 'logout' view doesn't require that the person is logged in.
if url == 'logout':
return self.logout(request)

# Check permission to continue or display login form.
if not self.has_permission(request):
return self.login(request)

if url == '':
return self.index(request)
elif url == 'password_change':
return self.password_change(request)
elif url == 'password_change/done':
return self.password_change_done(request)
elif url == 'jsi18n':
return self.i18n_javascript(request)
# URLs starting with 'r/' are for the "View on site" links.
elif url.startswith('r/'):
from django.contrib.contenttypes.views import shortcut
return shortcut(request, *url.split('/')[1:])
else:
if '/' in url:
return self.model_page(request, *url.split('/', 2))
else:
return self.app_index(request, url)

raise http.Http404('The requested admin page does not exist.')

def model_page(self, request, app_label, model_name, rest_of_url=None):
"""
DEPRECATED. This is the old way of handling a model view on the admin
site; the new views should use get_urls(), above.
"""
from django.db import models
model = models.get_model(app_label, model_name)
if model is None:
raise http.Http404("App %r, model %r, not found." % (app_label, model_name))
try:
admin_obj = self._registry[model]
except KeyError:
raise http.Http404("This model exists but has not been registered with the admin site.")
return admin_obj(request, rest_of_url)
model_page = never_cache(model_page)

# This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site.
site = AdminSite()
4 changes: 2 additions & 2 deletions django/contrib/auth/__init__.py
Expand Up @@ -22,12 +22,12 @@ def load_backend(path):
raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
if not hasattr(cls, "supports_object_permissions"):
warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
PendingDeprecationWarning)
DeprecationWarning)
cls.supports_object_permissions = False

if not hasattr(cls, 'supports_anonymous_user'):
warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
PendingDeprecationWarning)
DeprecationWarning)
cls.supports_anonymous_user = False
return cls()

Expand Down
4 changes: 2 additions & 2 deletions django/contrib/auth/models.py
Expand Up @@ -107,7 +107,7 @@ def create_user(self, username, email, password=None):
Creates and saves a User with the given username, e-mail and password.
"""
now = datetime.datetime.now()

# Normalize the address by lowercasing the domain part of the email
# address.
try:
Expand Down Expand Up @@ -380,7 +380,7 @@ def _get_message_set(self):
import warnings
warnings.warn('The user messaging API is deprecated. Please update'
' your code to use the new messages framework.',
category=PendingDeprecationWarning)
category=DeprecationWarning)
return self._message_set
message_set = property(_get_message_set)

Expand Down
6 changes: 6 additions & 0 deletions django/contrib/auth/tests/auth_backends.py
@@ -1,3 +1,5 @@
import warnings

from django.conf import settings
from django.contrib.auth.models import User, Group, Permission, AnonymousUser
from django.contrib.contenttypes.models import ContentType
Expand Down Expand Up @@ -152,9 +154,13 @@ def setUp(self):
self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test')
self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.auth')

def tearDown(self):
settings.AUTHENTICATION_BACKENDS = self.curr_auth
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)

def test_has_perm(self):
self.assertEqual(self.user1.has_perm('perm', TestObj()), False)
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/csrf/middleware.py
Expand Up @@ -3,5 +3,5 @@

import warnings
warnings.warn("This import for CSRF functionality is deprecated. Please use django.middleware.csrf for the middleware and django.views.decorators.csrf for decorators.",
PendingDeprecationWarning
DeprecationWarning
)
6 changes: 3 additions & 3 deletions django/contrib/gis/tests/__init__.py
Expand Up @@ -13,7 +13,7 @@ def run_gis_tests(test_labels, verbosity=1, interactive=True, failfast=False, ex
import warnings
warnings.warn(
'The run_gis_tests() test runner has been deprecated in favor of GeoDjangoTestSuiteRunner.',
PendingDeprecationWarning
DeprecationWarning
)
test_runner = GeoDjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
return test_runner.run_tests(test_labels, extra_tests=extra_tests)
Expand All @@ -22,7 +22,7 @@ class GeoDjangoTestSuiteRunner(DjangoTestSuiteRunner):

def setup_test_environment(self, **kwargs):
super(GeoDjangoTestSuiteRunner, self).setup_test_environment(**kwargs)

from django.db import connection
from django.contrib.gis.geos import GEOS_PREPARE
from django.contrib.gis.gdal import HAS_GDAL
Expand All @@ -49,7 +49,7 @@ def setup_test_environment(self, **kwargs):

self.geo_apps.append('layermap')

# Constructing the new INSTALLED_APPS, and including applications
# Constructing the new INSTALLED_APPS, and including applications
# within the GeoDjango test namespace (`self.geo_apps`).
new_installed = ['django.contrib.sites',
'django.contrib.sitemaps',
Expand Down
6 changes: 6 additions & 0 deletions django/contrib/messages/tests/base.py
@@ -1,3 +1,5 @@
import warnings

from django import http
from django.test import TestCase
from django.conf import settings
Expand Down Expand Up @@ -49,6 +51,8 @@ def setUp(self):
self._message_storage = settings.MESSAGE_STORAGE
settings.MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
self.storage_class.__name__)
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.auth.models')

def tearDown(self):
for setting in self.restore_settings:
Expand All @@ -59,6 +63,8 @@ def tearDown(self):
self._template_context_processors
settings.INSTALLED_APPS = self._installed_apps
settings.MESSAGE_STORAGE = self._message_storage
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)

def restore_setting(self, setting):
if setting in self._remembered_settings:
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/syndication/feeds.py
Expand Up @@ -10,7 +10,7 @@ class Feed(views.Feed):
def __init__(self, slug, request):
warnings.warn('The syndication feeds.Feed class is deprecated. Please '
'use the new class based view API.',
category=PendingDeprecationWarning)
category=DeprecationWarning)

self.slug = slug
self.request = request
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/syndication/views.py
Expand Up @@ -191,7 +191,7 @@ def feed(request, url, feed_dict=None):
import warnings
warnings.warn('The syndication feed() view is deprecated. Please use the '
'new class based view API.',
category=PendingDeprecationWarning)
category=DeprecationWarning)

if not feed_dict:
raise Http404("No feeds are registered.")
Expand Down
2 changes: 1 addition & 1 deletion django/core/cache/backends/memcached.py
Expand Up @@ -10,7 +10,7 @@
import warnings
warnings.warn(
"Support for the 'cmemcache' library has been deprecated. Please use python-memcached instead.",
PendingDeprecationWarning
DeprecationWarning
)
except ImportError:
try:
Expand Down
2 changes: 1 addition & 1 deletion django/core/context_processors.py
Expand Up @@ -24,7 +24,7 @@ def auth(request):
"The context processor at `django.core.context_processors.auth` is " \
"deprecated; use the path `django.contrib.auth.context_processors.auth` " \
"instead.",
PendingDeprecationWarning
DeprecationWarning
)
from django.contrib.auth.context_processors import auth as auth_context_processor
return auth_context_processor(request)
Expand Down
2 changes: 1 addition & 1 deletion django/core/mail/__init__.py
Expand Up @@ -106,6 +106,6 @@ def __init__(self, *args, **kwds):
import warnings
warnings.warn(
'mail.SMTPConnection is deprecated; use mail.get_connection() instead.',
PendingDeprecationWarning
DeprecationWarning
)
super(SMTPConnection, self).__init__(*args, **kwds)
2 changes: 1 addition & 1 deletion django/core/management/commands/test.py
Expand Up @@ -29,7 +29,7 @@ def handle(self, *test_labels, **options):
import warnings
warnings.warn(
'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
PendingDeprecationWarning
DeprecationWarning
)
failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive)
else:
Expand Down
6 changes: 3 additions & 3 deletions django/db/__init__.py
Expand Up @@ -15,7 +15,7 @@
import warnings
warnings.warn(
"settings.DATABASE_* is deprecated; use settings.DATABASES instead.",
PendingDeprecationWarning
DeprecationWarning
)

settings.DATABASES[DEFAULT_DB_ALIAS] = {
Expand Down Expand Up @@ -44,7 +44,7 @@
"django.contrib.gis is now implemented as a full database backend. "
"Modify ENGINE in the %s database configuration to select "
"a backend from 'django.contrib.gis.db.backends'" % alias,
PendingDeprecationWarning
DeprecationWarning
)
if database['ENGINE'] == 'postgresql_psycopg2':
full_engine = 'django.contrib.gis.db.backends.postgis'
Expand All @@ -56,7 +56,7 @@
warnings.warn(
"Short names for ENGINE in database configurations are deprecated. "
"Prepend %s.ENGINE with 'django.db.backends.'" % alias,
PendingDeprecationWarning
DeprecationWarning
)
full_engine = "django.db.backends.%s" % database['ENGINE']
database['ENGINE'] = full_engine
Expand Down
8 changes: 4 additions & 4 deletions django/db/backends/creation.py
Expand Up @@ -140,7 +140,7 @@ def sql_for_many_to_many(self, model, style):
import warnings
warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning
DeprecationWarning
)

output = []
Expand All @@ -154,7 +154,7 @@ def sql_for_many_to_many_field(self, model, f, style):
import warnings
warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning
DeprecationWarning
)

from django.db import models
Expand Down Expand Up @@ -217,7 +217,7 @@ def sql_for_inline_many_to_many_references(self, model, field, style):
import warnings
warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning
DeprecationWarning
)

from django.db import models
Expand Down Expand Up @@ -322,7 +322,7 @@ def sql_destroy_many_to_many(self, model, f, style):
import warnings
warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning
DeprecationWarning
)

qn = self.connection.ops.quote_name
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/postgresql/base.py
Expand Up @@ -105,7 +105,7 @@ def __init__(self, *args, **kwargs):
import warnings
warnings.warn(
'The "postgresql" backend has been deprecated. Use "postgresql_psycopg2" instead.',
PendingDeprecationWarning
DeprecationWarning
)

self.features = DatabaseFeatures()
Expand Down
8 changes: 4 additions & 4 deletions django/db/models/fields/subclassing.py
Expand Up @@ -15,14 +15,14 @@ def call_with_connection(func):
if not updated:
warn("A Field class whose %s method hasn't been updated to take a "
"`connection` argument." % func.__name__,
PendingDeprecationWarning, stacklevel=2)
DeprecationWarning, stacklevel=2)

def inner(*args, **kwargs):
if 'connection' not in kwargs:
from django.db import connection
kwargs['connection'] = connection
warn("%s has been called without providing a connection argument. " %
func.__name__, PendingDeprecationWarning,
func.__name__, DeprecationWarning,
stacklevel=1)
if updated:
return func(*args, **kwargs)
Expand All @@ -40,14 +40,14 @@ def call_with_connection_and_prepared(func):
if not updated:
warn("A Field class whose %s method hasn't been updated to take "
"`connection` and `prepared` arguments." % func.__name__,
PendingDeprecationWarning, stacklevel=2)
DeprecationWarning, stacklevel=2)

def inner(*args, **kwargs):
if 'connection' not in kwargs:
from django.db import connection
kwargs['connection'] = connection
warn("%s has been called without providing a connection argument. " %
func.__name__, PendingDeprecationWarning,
func.__name__, DeprecationWarning,
stacklevel=1)
if updated:
return func(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion django/db/utils.py
Expand Up @@ -23,7 +23,7 @@ def load_backend(backend_name):
import warnings
warnings.warn(
"Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'",
PendingDeprecationWarning
DeprecationWarning
)
return module
except ImportError, e:
Expand Down
2 changes: 1 addition & 1 deletion django/forms/fields.py
Expand Up @@ -50,7 +50,7 @@ def en_format(name):
from django.conf.locale.en import formats
warnings.warn(
"`django.forms.fields.DEFAULT_%s` is deprecated; use `django.utils.formats.get_format('%s')` instead." % (name, name),
PendingDeprecationWarning
DeprecationWarning
)
return getattr(formats, name)

Expand Down
2 changes: 1 addition & 1 deletion django/middleware/csrf.py
Expand Up @@ -274,7 +274,7 @@ def __init__(self):
import warnings
warnings.warn(
"CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).",
PendingDeprecationWarning
DeprecationWarning
)

def process_response(self, request, response):
Expand Down

0 comments on commit 1070c57

Please sign in to comment.