Changeset 6108 for django/branches/gis/django/contrib/gis/sitemaps.py
- Timestamp:
- 09/12/07 08:04:33 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/sitemaps.py
r5751 r6108 2 2 from django.contrib.sitemaps import Sitemap 3 3 from django.contrib.gis.db.models.fields import GeometryField 4 from django.contrib.gis.shortcuts import render_to_kml 4 5 from django.db.models import get_model, get_models 5 from django.template.loader import get_template6 from django.template import Context7 6 from django.http import HttpResponse 8 9 kml_files = [('gis.school', 'location'),10 ('gis.district', 'boundary')]11 12 7 13 8 class KMLSitemap(Sitemap): 14 9 """ 15 A minimal hook to 10 A minimal hook to produce KML sitemaps. 16 11 """ 17 12 def __init__(self, locations=None): … … 28 23 kwargs={'label':obj[0], 29 24 'field_name':obj[1]}) 30 31 25 32 26 def _build_kml_sources(): … … 46 40 pass 47 41 48 49 42 def kml(request, label, field_name): 50 43 placemarks = [] … … 52 45 if not klass: 53 46 raise KMLNotFound("You must supply a valid app.model label. Got %s" % label) 47 54 48 #FIXME: GMaps apparently has a limit on size of displayed kml files 55 49 # check if paginating w/ external refs (i.e. linked list) helps. 56 50 placemarks.extend(list(klass._default_manager.kml(field_name)[:100])) 51 57 52 #FIXME: other KML features? 58 t = get_template('gis/kml.xml')59 c = Context({'places':placemarks}) 53 return render_to_kml('gis/kml/placemarks.kml', {'places' : placemarks}) 54 60 55 61 return HttpResponse(t.render(c), mimetype='application/vnd.google-earth.kml+xml')62
