-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.py
36 lines (29 loc) · 1.17 KB
/
post.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
from rssparser import *
from google.appengine.ext import db
def post_key(name = 'default'):
return db.Key.from_path('posts', name)
class Post(db.Model):
title = db.TextProperty(required = True)
description = db.TextProperty(required = True)
pubDate = db.DateTimeProperty(required = True)
link = db.TextProperty(required = True)
content = db.BlobProperty()
image = db.LinkProperty()
src = db.StringProperty(required = True)
def render(self):
return render_str("post.html", p = self)
links = {}
class ParseRSS(RssParser):
def get(self):
results = self.parse_rss()
for r in results:
if r.link not in links:
logging.error("New Post Entity Being Created")
p = Post(parent = post_key(), title = r.title,
description = r.description,
link = r.link, content = r.content,
image = r.image, pubDate = r.pubDate,
src = r.src)
p.put()
links[r.link] = True
app = webapp2.WSGIApplication([('/parser', ParseRSS)], debug=True)