From 5485e0d97f86b04bd257e391986b62b1cff1c90a Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Tue, 26 Aug 2008 00:46:30 +0000 Subject: [PATCH] Fixes for Geo sitemap errata. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8566 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/gis/sitemaps/georss.py | 2 +- django/contrib/gis/sitemaps/views.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/django/contrib/gis/sitemaps/georss.py b/django/contrib/gis/sitemaps/georss.py index 45c97fb8a2..ecd1171842 100644 --- a/django/contrib/gis/sitemaps/georss.py +++ b/django/contrib/gis/sitemaps/georss.py @@ -41,7 +41,7 @@ class GeoRSSSitemap(Sitemap): This method is overrridden so the appropriate `geo_format` attribute is placed on each URL element. """ - urls = Sitemap.get_urls(self) + urls = Sitemap.get_urls(self, page=page) for url in urls: url['geo_format'] = 'georss' return urls diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index d20f7c6d20..782a1b9ce3 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -5,13 +5,11 @@ from django.contrib.sites.models import Site from django.core import urlresolvers from django.core.paginator import EmptyPage, PageNotAnInteger from django.db.models import get_model +from django.contrib.gis.db.models.fields import GeometryField from django.utils.encoding import smart_str from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz -class KMLNotFound(Exception): - pass - def index(request, sitemaps): """ This view generates a sitemap index that uses the proper view @@ -71,7 +69,15 @@ def kml(request, label, model, field_name=None, compress=False): placemarks = [] klass = get_model(label, model) if not klass: - raise KMLNotFound("You must supply a valid app.model label. Got %s.%s" % (label, model)) + raise Http404('You must supply a valid app label and module name. Got "%s.%s"' % (label, model)) + + if field_name: + try: + info = klass._meta.get_field_by_name(field_name) + if not isinstance(info[0], GeometryField): + raise Exception + except: + raise Http404('Invalid geometry field.') if SpatialBackend.postgis: # PostGIS will take care of transformation.