Example #1
0
 def GET(self):
     from util.feedgenerator import Atom1Feed
     
     blog = Blog.get()
     blog_home = web.ctx.home
     feed = Atom1Feed(
         title=blog.name,
         link=blog_home,
         description=blog.description,
     )
     posts = Post.all().filter('hidden =', False).order('-date').fetch(10)
     for post in posts:
         if post.category:
             category = (post.category.name,)
         else:
             category = ()
         if post.tags:
             category = category + tuple(post.tags)
         feed.add_item(title=post.title,
                       link=blog_home + post.getUrl(),
                       description=post.content,
                       pubdate=post.date,
                       categories=category
                       )
     web.header('Content-Type', 'application/atom+xml')
     return feed.writeString('utf-8')
Example #2
0
 def body(self):
     content = memcache.get('widget_post_list')
     if not content:
         post_list = Post.all().filter('hidden =',False)\
                         .order('-date').fetch(10)
     
         content = []
         write = content.append
         write('<ul>')
         for post in post_list:
             write('<li><a href="%s">%s</a></li>' %
                         (post.getUrl(), post.title))
         write('</ul>')
         content = '\n'.join(content)
         memcache.set('widget_post_list', content)
     
     return content