From 5c61b8519d8ce02e4308201f3e81fdc99ad80b58 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 7 Dec 2013 19:28:01 +0100 Subject: [PATCH] Fixed #18531 -- Deprecated Geo Sitemaps I've chosen a quick deprecation path, as Geo Sitemaps themselves are deprecated from some time now. --- django/contrib/gis/sitemaps/views.py | 6 ++++++ django/contrib/gis/tests/geoapp/test_sitemaps.py | 5 ++++- docs/internals/deprecation.txt | 4 ++++ docs/releases/1.7.txt | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index c4c08de8f5..0672b800cc 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +import warnings + from django.http import HttpResponse, Http404 from django.template import loader from django.contrib.sites.models import get_current_site @@ -20,6 +22,8 @@ def index(request, sitemaps): This view generates a sitemap index that uses the proper view for resolving geographic section sitemap URLs. """ + warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from " + "django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2) current_site = get_current_site(request) sites = [] protocol = request.scheme @@ -43,6 +47,8 @@ def sitemap(request, sitemaps, section=None): This view generates a sitemap with additional geographic elements defined by Google. """ + warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from " + "django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2) maps, urls = [], [] if section is not None: if section not in sitemaps: diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py index d9ede80c57..0439a37644 100644 --- a/django/contrib/gis/tests/geoapp/test_sitemaps.py +++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py @@ -11,6 +11,7 @@ from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.tests.utils import HAS_SPATIAL_DB from django.contrib.sites.models import Site from django.test import TestCase +from django.test.utils import IgnoreDeprecationWarningsMixin from django.utils._os import upath if HAS_GEOS: @@ -18,17 +19,19 @@ if HAS_GEOS: @skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.") -class GeoSitemapTest(TestCase): +class GeoSitemapTest(IgnoreDeprecationWarningsMixin, TestCase): urls = 'django.contrib.gis.tests.geoapp.urls' def setUp(self): + super(GeoSitemapTest, self).setUp() Site(id=settings.SITE_ID, domain="example.com", name="example.com").save() self.old_Site_meta_installed = Site._meta.installed Site._meta.installed = True def tearDown(self): Site._meta.installed = self.old_Site_meta_installed + super(GeoSitemapTest, self).tearDown() def assertChildNodes(self, elem, expected): "Taken from syndication/tests.py." diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 4c44c70501..2e53901536 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -147,6 +147,10 @@ these changes. * The session key ``django_language`` will no longer be read for backwards compatibility. +* Geographic Sitemaps will be removed + (``django.contrib.gis.sitemaps.views.index`` and + ``django.contrib.gis.sitemaps.views.sitemap``). + 1.9 --- diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 0d37a8d99a..5014358ae9 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -854,3 +854,9 @@ The function ``memoize`` is deprecated and should be replaced by the Django ships a backport of this decorator for older Python versions and it's available at ``django.utils.lru_cache.lru_cache``. The deprecated function will be removed in Django 1.9. + +Geo Sitemaps +~~~~~~~~~~~~ + +Google has retired support for the Geo Sitemaps format. Hence Django support +for Geo Sitemaps is deprecated and will be removed in Django 1.8.