def get(self, thiskey): curr = Source.get(thiskey) for item in curr.item_set: item.delete() curr.delete() self.redirect("/sources")
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): s = Source.all().order("modified").fetch(limit=100) user = users.get_current_user() if user: url = users.create_logout_url("/") else: url = None sources_list = split_list(s, 3) template_values = {"a": sources_list[0], "b": sources_list[1], "c": sources_list[2], "url": url} path = os.path.join(os.path.dirname(__file__), "templates/index.html") self.response.out.write(template.render(path, template_values))
def get(self): sources = Source.all() items = Item.all() json = simplejson.dumps({"sources": [s.to_dict() for s in sources], "items": [i.to_dict() for i in items]}) self.response.out.write(json)
def get(self): sources = Source.all() for source in sources: taskqueue.add(url="/sources/refresh", params={"key": source.key()})
def post(self): source = Source(name=self.request.get("source_title"), path=self.request.get("source_url")) source.put() taskqueue.add(url="/sources/refresh", params={"key": source.key()}) self.redirect("/sources")
def get(self): sources = Source.all() template_values = {"sources": sources} path = os.path.join(os.path.dirname(__file__), "templates/sources.html") self.response.out.write(template.render(path, template_values))