def post(self, id): homeBase.init(self) self.title = 'Edit Profile' ucollege = self.get_argument('ucollege', default='') ugrade = self.get_argument('ugrade', default='') udomain = self.get_argument('udomain', default='') ubio = self.get_argument('ubio', default='') user = self.session.query(User).filter(User.username == self.signeduser).first() user.ucollege = ucollege user.ugrade = ugrade user.udomain = udomain user.ubio = ubio print user.uavatar print ubio, ugrade, ucollege if 'file' in self.request.files: file_dict_list = self.request.files['file'] for file_dict in file_dict_list: filename = nameRewrite(file_dict["filename"]).encode('utf8') data = file_dict["body"] image = Image.open(StringIO(data)) image.save(avatar_path + filename, quality=150) ''' with open(avatar_path + filename, 'w') as f: f.write(data) print filename''' user.uavatar = '/static/avatar/' + filename else: if user.uavatar == '': user.uavatar = '/static/images/' + 'avatar-'+ str(random.randint(1,16)) +'.svg' print user.uavatar self.session.commit() self.write('<script language="javascript">alert("OK,Entering your own homepage!!");self.location="/members/m/%s";</script>' % str(self.signedid)) self.session.close()
def post(self): homeBase.init(self) cname = self.get_argument('cname', default='') ccollege = self.get_argument('ccollege', default='') ccemail = self.get_argument('ccemail', default='') creason = self.get_argument('creason', default='') contact = Contact(cname, ccollege, ccemail, creason) if 'file' in self.request.files: file_dict_list = self.request.files['file'] for file_dict in file_dict_list: filename = nameRewrite(file_dict["filename"]).encode('utf8') data = file_dict["body"] with open(resume_path + filename, 'w') as f: f.write(data) print filename contact.cresume = '/static/resume/' + filename self.session.add(contact) self.session.commit() self.write('<script language="javascript">alert("提交成功");self.location="/";</script>') self.session.close()