<s> import cStringIO , zipfile <EOL> from django . conf import settings <EOL> from django . http import HttpResponse <EOL> from django . template import loader <EOL> def compress_kml ( kml ) : <EOL> "<STR_LIT>" <EOL> kmz = cStringIO . StringIO ( ) <EOL> zf = zipfile . ZipFile ( kmz , '<STR_LIT:a>' , zipfile . ZIP_DEFLATED ) <EOL> zf . writestr ( '<STR_LIT>' , kml . encode ( settings . DEFAULT_CHARSET ) ) <EOL> zf . close ( ) <EOL> kmz . seek ( <NUM_LIT:0> ) <EOL> return kmz . read ( ) <EOL> def render_to_kml ( * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> return HttpResponse ( loader . render_to_string ( * args , ** kwargs ) , <EOL> mimetype = '<STR_LIT>' ) <EOL> def render_to_kmz ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return HttpResponse ( compress_kml ( loader . render_to_string ( * args , ** kwargs ) ) , <EOL> mimetype = '<STR_LIT>' ) <EOL> def render_to_text ( * args , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> return HttpResponse ( loader . render_to_string ( * args , ** kwargs ) , <EOL> mimetype = '<STR_LIT>' ) </s>
