20090810

sitemap generator

Old one "sitemap_gen.py" digs presentation (our projector and cabling) and logs (junk) where this goes straight storage to gz. Premise: /[id]/[title]
Comment: Premise rests on R&D opinion yet to standardize since viceversa (/[title]/[id]) is easier to remember but conflicts different items with same titles which can't keep uniqums

    url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else os.environ['SERVER_NAME']   
output = '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" >'
for ad in Ad.gql("where published = True and modified >:1 order by modified desc", datetime.now() - timedelta (days = days)):
output = '%s<url><loc>http://%s/%d/%s</loc><lastmod>%s</lastmod><changefreq>daily</changefreq><priority>0.8</priority></url>' %( output, url,ad.key().id(),defaultfilters.slugify(ad.title),ad.modified.date())
output = '%s</urlset>' %output
self.response.headers['Content-Type'] = 'gzip'
self.response.headers['Content-Length'] = str(len(output))
self.response.out.write(compressBuf(output))

1 comment:

Anonymous said...

thuc, can we trade links?