Ejemplo n.º 1
0
def getSitemap():
    mc_key = 'sitemap'
    val = memcache.get(mc_key)
    if val is None:
        sitemap = []
        sitemap.append('<?xml version="1.0" encoding="UTF-8"?>')
        sitemap.append('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
        quotes = db.getQuotes()
        for quote in quotes:
            entry = '<url><loc>%s</loc></url>' % (quote.getLink())
            sitemap.append(entry)
        sitemap.append('</urlset>')
        val = u'\r\n'.join(sitemap)
        memcache.set(mc_key, val, settings.page_cache_duration)
    return val
Ejemplo n.º 2
0
 def get(self):
     self.verifyUrl()
     self.response.headers['Cache-Control'] = settings.cache_control
     cached = getCachedPage('list')
     if cached:
         self.send(cached)
     else:
         quotes = db.getQuotes()
         quotes.sort(key=operator.attrgetter('date'), reverse=True)
         dates = [x.date.strftime('%Y-%m-%d') for x in quotes]
         ids = [x.key().id() for x in quotes]
         items = zip(quotes, dates, ids)
         template_values = {
             'items': items,
         }
         self.send(getPage('list', 'view/list.html', template_values))