def more(self, id=None): # id will be something like d_ping_[ping.id] # so, I want to get a ping where id > that one. pid = id.split('_')[-1] try: pid = int(pid) except: log.debug("couldn't identify the ping %s "%id) return "" c.username = session.get('user') c.fl_mod = session.get('mod',False) for ping in PseudoPing.query().filter( PseudoPing.fl_decided==False).filter(PseudoPing.id>pid).order_by(PseudoPing.id): img = ping.Image_fromPing() if img.in_pool(): c.ping=ping c.image=ping.image c.atts = img.all_atts() return render('one_ping.mako') else: ping.fl_decided=True ping.commit() #Guess what. We're empty. get to bottom, go back to top. But this time, we need # to send back the newest image, rather than the next oldest one. if not self._reload(): return return self.more(id)
def index(self): c.results=[] c.username = session.get('user') c.fl_mod = session.get('mod',False) images = {} flSave = False for ping in PseudoPing.query().filter(PseudoPing.fl_decided==False).order_by(PseudoPing.id): if not images.get(ping.image): img = ping.Image_fromPing() if img.in_pool(): images[ping.image] = True c.results.append(ping) if len(c.results) >= 2: break else: flSave=True ping.fl_decided=True if not len(c.results): if self.reload(): return self.index() if flSave: ping.commit() return render('ping.mako')