def post(self): code=self.request.get('imagecode','') codename=self.request.get('codename','') codestr=memcache.get(codename) success=False msg=u'' jokeid=self.request.get('jokeid') face=self.request.get('face') fatherid_id=self.request.get('fatherid_id') content=self.request.get('content','') content=content.replace('<','<') content=content.replace('>','>') if codestr==code: user_joke=get_current_user(self) replay=Replay() replay.joke=jokeid if fatherid_id: replay.fatherid_id=int(fatherid_id) replay.content=content replay.face=int(face) replay.user=user_joke.key().id() replay.updateTime=datetime.datetime.utcnow()+timezone replay.put() num=memcache.get('replayjokenum'+jokeid) if num!=None: memcache.set('replayjokenum'+jokeid,num+1,720000) memcache_delete('replayjoke'+jokeid) self.redirect('/%s.html'%jokeid) else: self.redirect('/%s.html'%jokeid)
def get(self): jokeid=self.request.get('jokeid') html=memcache_get('replayjoke'+jokeid) if not html: replaylist=[] for replay in Replay.all().filter('joke =',jokeid).order('-updateTime'): rmap={} rmap['id']=replay.key().id() rmap['jokeid']=replay.joke rmap['face']=replay.face rmap['content']=replay.content rmap['createDate']=replay.updateTime.strftime('%Y年%m月%d日 %H:%M:%S') rmap['fatherid']=replay.fatherid_id rmap['userid']=replay.user rmap['username']=getUserName(replay.user) replaylist.append(rmap) html=json.dumps(replaylist) memcache_set('replayjoke'+jokeid,html,7200) self.flashhtml(html)
def post(self,jokeid=None): num=memcache.get('replayjokenum'+jokeid) if num==None: num=Replay.all().filter('joke =',jokeid).count() memcache.set('replayjokenum'+jokeid,num,720000) self.flashhtml('{"success":true,"replaynum":%s}'%num)