Fixed #18531 -- Deprecated Geo Sitemaps

I've chosen a quick deprecation path, as Geo Sitemaps themselves
are deprecated from some time now.
This commit is contained in:
Claude Paroz 2013-12-07 19:28:01 +01:00
parent a7cf48a2b7
commit 5c61b8519d
4 changed files with 20 additions and 1 deletions

View File

@ -1,5 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import warnings
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.template import loader from django.template import loader
from django.contrib.sites.models import get_current_site 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 This view generates a sitemap index that uses the proper view
for resolving geographic section sitemap URLs. 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) current_site = get_current_site(request)
sites = [] sites = []
protocol = request.scheme protocol = request.scheme
@ -43,6 +47,8 @@ def sitemap(request, sitemaps, section=None):
This view generates a sitemap with additional geographic This view generates a sitemap with additional geographic
elements defined by Google. elements defined by Google.
""" """
warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from "
"django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2)
maps, urls = [], [] maps, urls = [], []
if section is not None: if section is not None:
if section not in sitemaps: if section not in sitemaps:

View File

@ -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.gis.tests.utils import HAS_SPATIAL_DB
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.test import TestCase from django.test import TestCase
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils._os import upath from django.utils._os import upath
if HAS_GEOS: if HAS_GEOS:
@ -18,17 +19,19 @@ if HAS_GEOS:
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.") @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' urls = 'django.contrib.gis.tests.geoapp.urls'
def setUp(self): def setUp(self):
super(GeoSitemapTest, self).setUp()
Site(id=settings.SITE_ID, domain="example.com", name="example.com").save() Site(id=settings.SITE_ID, domain="example.com", name="example.com").save()
self.old_Site_meta_installed = Site._meta.installed self.old_Site_meta_installed = Site._meta.installed
Site._meta.installed = True Site._meta.installed = True
def tearDown(self): def tearDown(self):
Site._meta.installed = self.old_Site_meta_installed Site._meta.installed = self.old_Site_meta_installed
super(GeoSitemapTest, self).tearDown()
def assertChildNodes(self, elem, expected): def assertChildNodes(self, elem, expected):
"Taken from syndication/tests.py." "Taken from syndication/tests.py."

View File

@ -147,6 +147,10 @@ these changes.
* The session key ``django_language`` will no longer be read for backwards * The session key ``django_language`` will no longer be read for backwards
compatibility. compatibility.
* Geographic Sitemaps will be removed
(``django.contrib.gis.sitemaps.views.index`` and
``django.contrib.gis.sitemaps.views.sitemap``).
1.9 1.9
--- ---

View File

@ -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 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 available at ``django.utils.lru_cache.lru_cache``. The deprecated function will
be removed in Django 1.9. 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.