def have_id(self): """ Fetches a specific comic and finds the previous and next comics. """ self.current_comic = RabiaStore.get(self.img_id) self.get_prev_and_next() json = self.current_comic.json self.template_values['imgur_url'] = self.current_comic.url self.template_values['current_comic_id'] = self.img_id self.template_values['reddit_title'] = json['title'] self.template_values['reddit_permalink'] = json['permalink'] self.template_values['nsfw'] = bool(json['over_18']) # Serialize this data so we can store it in memcache self.json_template_values = simplejson.dumps(self.template_values)
def have_id(self): img_id = self.request.get("img") current_comic = RabiaStore.get(img_id) next_comic = RabiaStore.all().filter("datetime <", current_comic.datetime).order("-datetime") next_comic = next_comic.get() prev_comic = RabiaStore.all().filter("datetime >", current_comic.datetime).order("datetime") prev_comic = prev_comic.get() if next_comic is not None: next_comic = next_comic.key() else: next_comic = False if prev_comic is not None: prev_comic = prev_comic.key() else: prev_comic = False self.template_values = { "prev_comic_id": prev_comic, "next_comic_id": next_comic, "imgur_url": current_comic.url, }