Try:

output = template.render(path, template_values)
self.response.headers['Content-Length'] = len(output)
self.response.out.write(output)

On Mon, Apr 11, 2011 at 4:09 PM, Niklas Rosencrantz <[email protected]> wrote:
> Certainly. Thanks for all the great help. Here is what fills the template
>
> from datetime import tzinfo
> class GMT(tzinfo):
>     def utcoffset(self, dt):
>         return timedelta(hours=10) # + self.dst(dt)
>     def tzname(self, dt):
>         return "GMT"
>     def dst(self, dt):
>         return timedelta(0)
> DELTA = timedelta(days=1)
> DELTA_SECONDS = DELTA.days * 86400 + DELTA.seconds
> gmt = GMT()
> EXPIRATION_MASK = "%a, %d %b %Y %H:%M:%S %Z"
>
> class KMLHandler(webapp.RequestHandler):#make cron job and store with
> memcache
>  def get(self):
>     # def get
>     expiration = datetime.datetime.now()
>     expiration = expiration.replace(tzinfo=gmt)
>     expiration = expiration + DELTA
>     self.response.headers["Expires"] =expiration.strftime(EXPIRATION_MASK)
>     self.response.headers["Cache-Control"] = "public,max-age=%s" % 86400
>
>     start=datetime.datetime.now()-timedelta(days=20)#vary
>     host = os.environ.get("HTTP_HOST", os.environ["SERVER_NAME"])
>     logging.debug('host '+host)
>     count = int(self.request.get('count')) if not
> self.request.get('count')=='' else 1000
>     from google.appengine.api import memcache
>     memcache.flush_all()
>     memcache_key = "ads"
>     data = memcache.get(memcache_key)
>     if data is None:
>       a= Ad.all().filter("modified >", start).filter("url IN",
> ['www.koolbusiness.com']).filter("published =",
> True).order("-modified").fetch(count)
>       memcache.set("ads", a)
>     else:
>       a = data
>     dispatch='templates/kml.html'
>     template_values = {'a': a , 'request':self.request, 'host':host}
>     path = os.path.join(os.path.dirname(__file__), dispatch)
>     self.response.headers['Content-Type'] =
> 'application/vnd.google-earth.kml+xml'
>     self.response.out.write(template.render(path, template_values))
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to