Try if you like gzipped sitemap.xml.gz approved via google webmaster
tools, Http header: "Content-Type: gzip
"
import zlib
import gzip
import string
import os
import gzip
import StringIO
class SiteMap(webapp.RequestHandler):
def get(self):
start = datetime.now() - timedelta (days = 91)
url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else
os.environ['SERVER_NAME']
items= Item.gql("where published = True and modified >:1", start)
output = '<?xml version="1.0" encoding="UTF-8"?><urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" >'
for item in items:
output =output + '<url><loc>http://%s/%s/%s</loc><lastmod>%s</
lastmod><changefreq>daily</changefreq><priority>0.8</priority></url>'
%( url,item.key().id(),defaultfilters.slugify
(item.title),item.modified.date() )
output = output + '</urlset>'
self.response.headers["Content-Type"] = 'gzip'
buf = compressBuf(output)
self.response.headers['Content-Length'] = str(len(output))
self.response.out.write(buf)
def compressBuf(buf):
zbuf = StringIO.StringIO()
zfile = gzip.GzipFile(None, 'wb', 9, zbuf)
zfile.write(buf)
zfile.close()
return zbuf.getvalue()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---