Exemplo n.º 1
0
    def get(self):
        posts = Post.all().order('-created').fetch(20)
        prefetch.prefetch_posts_list(posts)

        items = []
        for post in posts:
            if len(post.message) == 0:
                rss_poster = '<a href="' + post.url + '">' + post.url + '</a>'
            else:
                rss_poster = post.message
            rss_poster += ' por <a href="' + helper.base_url(
                self
            ) + '/perfil/' + post.user.nickname + '">' + post.user.nickname + '</a>'

            link = helper.base_url(self) + '/noticia/' + str(post.key())
            if post.nice_url:
                link = helper.base_url(self) + '/noticia/' + str(post.nice_url)

            items.append(
                PyRSS2Gen.RSSItem(title=post.title,
                                  link=link,
                                  description=rss_poster,
                                  guid=PyRSS2Gen.Guid("guid1"),
                                  pubDate=post.created))

        rss = PyRSS2Gen.RSS2(title="Noticias Hacker",
                             link="http://noticiashacker.com/",
                             description="Noticias Hacker",
                             lastBuildDate=datetime.now(),
                             items=items)
        print 'Content-Type: text/xml'
        self.response.out.write(rss.to_xml('utf-8'))
Exemplo n.º 2
0
    def get(self):
        posts = Post.all().order('-created').fetch(20)
        prefetch_posts_list(posts)

        items = []
        for post in posts:
            items.append(
                PyRSS2Gen.RSSItem(title=post.title,
                                  link="http://noticiashacker.com/noticia/" +
                                  str(post.key()),
                                  description="",
                                  guid=PyRSS2Gen.Guid("guid1"),
                                  pubDate=post.created))

        rss = PyRSS2Gen.RSS2(title="Noticias Hacker",
                             link="http://noticiashacker.com/",
                             description="",
                             lastBuildDate=datetime.now(),
                             items=items)
        print 'Content-Type: text/xml'
        self.response.out.write(rss.to_xml('utf-8'))