-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.py
46 lines (34 loc) · 1.24 KB
/
feed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import datetime
import logging
from google.appengine.ext import webapp
from vendor import PyRSS2Gen
from models.post import Post
class FeedHandler(webapp.RequestHandler):
def get(self):
rss_items = []
# fetch all posts from the db
logging.info("FeedHandler::get() - Fetching posts from the db")
q = Post.all()
q.order("-created_at")
results = q.fetch(20)
for p in results:
rss_items.append(
PyRSS2Gen.RSSItem(
title = "Tasty Burger Friday",
link = "http://www.tasty-babelsberg.de",
description = p.content,
# guid = PyRSS2Gen.Guid('Guid{0}'.format(p.key().id())),
pubDate = p.created_at
)
)
logging.info("Building the RSS")
# build the rss
rss = PyRSS2Gen.RSS2(
title = "Tasty Burger Feed",
link = "http://www.tasty-babelsberg.de",
description = "Tasty Burger Friday",
lastBuildDate = datetime.datetime.now(),
items = rss_items
)
self.response.headers['Content-Type'] = 'application/rss+xml'
self.response.out.write(rss.to_xml())