def get(self): groupid=self.request.get('groupid','') userName=self.request.get("UserName") weiUser=getWeiUser(userName,groupid) nickname=getNickName(userName) result='{"result":"%s","message":"%s","url":"%s","obj":"%s"}' resultObj={'group':weiUser.group,'userid':weiUser.user,'point':weiUser.point,'tempPoint':weiUser.tempPoint,'nickname':nickname} self.flashhtml(result%('success',u'','',json.dumps(resultObj)))
def post(self): groupid=self.request.get('groupid',0) weinoteid=self.request.get('weinoteid','') title=self.request.get('title','') content=self.request.get('content','') type=self.request.get('type','0') image_list=self.request.get('image_list','') author=self.request.get('author','') if not groupid or not title or not author: self.flashhtml(resultStr%('fail',u'标题、群号、用户号为必填项。','')) return try: if not weinoteid: weinote=WeiNote() else: weinote=WeiNote.get_by_id(int(weinoteid)) weinote.group=int(groupid) weinote.title=title weinote.content=content weinote.type=int(type) for imageid in image_list.split(','): weinote.image_list.append(int(imageid)) if author[0]=='u': weinote.author=author else: weinote.author='u'+author weinote.updateTime=datetime.datetime.utcnow()+timezone weinote.put() if not weinoteid: weiNotePoint=WeiNotePoint(key_name='n%s'%weinote.key().id()) weiNotePoint.group=int(groupid) weiUser=getWeiUser(weinote.author,str(groupid)) if weiUser: weiNotePoint.point=weiUser.point else: weiNotePoint.point=0 weiNotePoint.put() self.flashhtml(resultStr%('success',u'发布帖子成功。','')) else: self.flashhtml(resultStr%('success',u'修改帖子成功。','')) return except Exception,e: self.flashhtml(resultStr%('fail',u'服务器异常,请稍后再操作。','')) logging.error(str(e)) return