def post(self): source_key = self.request.get("key") source = Source.get(source_key) if source: source.lock = True source.put() try: s = urlfetch.fetch(url=source.path) if s.status_code == 200: d = feedparser.parse(s.content) source.title = d.feed.title source.link = d.feed.link for item in source.item_set: item.delete() for item in d.entries: i = Item(title=item.title, path=item.link, source=source) if "description" in item: i.excerpt = item.description else: i.excerpt = item.title # i.published = item.updated_parsed i.put() except: print "error" finally: source.lock = False source.put()
def get(self, thiskey): curr = Source.get(thiskey) for item in curr.item_set: item.delete() curr.delete() self.redirect("/sources")