mirror of https://github.com/django/django.git
Fixed #11624: `render_to_kmz` no longer balks on non-ASCII data.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11527 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
677ddcbb04
commit
1aef132090
|
@ -1,4 +1,5 @@
|
|||
import cStringIO, zipfile
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
from django.template import loader
|
||||
|
||||
|
@ -6,7 +7,7 @@ def compress_kml(kml):
|
|||
"Returns compressed KMZ from the given KML string."
|
||||
kmz = cStringIO.StringIO()
|
||||
zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED)
|
||||
zf.writestr('doc.kml', kml)
|
||||
zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET))
|
||||
zf.close()
|
||||
kmz.seek(0)
|
||||
return kmz.read()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os, unittest
|
||||
from django.contrib.gis.db.backend import SpatialBackend
|
||||
from django.contrib.gis.tests.utils import no_mysql, no_oracle, no_postgis
|
||||
from django.contrib.gis.shortcuts import render_to_kmz
|
||||
from models import City
|
||||
|
||||
class GeoRegressionTests(unittest.TestCase):
|
||||
|
@ -16,3 +17,13 @@ class GeoRegressionTests(unittest.TestCase):
|
|||
self.assertEqual(pnt, City.objects.get(name='Pueblo').point)
|
||||
City.objects.filter(name='Pueblo').update(point=bak)
|
||||
self.assertEqual(bak, City.objects.get(name='Pueblo').point)
|
||||
|
||||
def test02_kmz(self):
|
||||
"Testing `render_to_kmz` with non-ASCII data, see #11624."
|
||||
name = '\xc3\x85land Islands'.decode('iso-8859-1')
|
||||
places = [{'name' : name,
|
||||
'description' : name,
|
||||
'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
|
||||
}]
|
||||
kmz = render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
|
||||
|
||||
|
|
Loading…
Reference in New Issue