Fixes for Geo sitemap errata.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8566 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2008-08-26 00:46:30 +00:00
parent 8a88379b2a
commit 5485e0d97f
2 changed files with 11 additions and 5 deletions

View File

@ -41,7 +41,7 @@ class GeoRSSSitemap(Sitemap):
This method is overrridden so the appropriate `geo_format` attribute This method is overrridden so the appropriate `geo_format` attribute
is placed on each URL element. 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' for url in urls: url['geo_format'] = 'georss'
return urls return urls

View File

@ -5,13 +5,11 @@ from django.contrib.sites.models import Site
from django.core import urlresolvers from django.core import urlresolvers
from django.core.paginator import EmptyPage, PageNotAnInteger from django.core.paginator import EmptyPage, PageNotAnInteger
from django.db.models import get_model 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.utils.encoding import smart_str
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
class KMLNotFound(Exception):
pass
def index(request, sitemaps): 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
@ -71,7 +69,15 @@ def kml(request, label, model, field_name=None, compress=False):
placemarks = [] placemarks = []
klass = get_model(label, model) klass = get_model(label, model)
if not klass: 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: if SpatialBackend.postgis:
# PostGIS will take care of transformation. # PostGIS will take care of transformation.