Exemple #1
0
 def post(self):            
     user_key =self.get_secure_cookie("user_key")
     r = None
     
     user_data = {}
     info_data = {}
     
     
     userInfo = UserInfo()
     user = User()
     user.key = user_key
     user.data = user.get(user_key)
     user.data['nickname'] = self.get_argument("user_nickname",None)
     
     userInfo.key = user_key
     
     userInfo_data = userInfo.get(user_key)
     if userInfo_data:
         userInfo.data = userInfo_data
         
     userInfo.data['city']        = self.get_argument("user_city","")
     userInfo.data['url']         = self.get_argument("user_url","")
     userInfo.data['desc']        = self.get_argument("user_description","")
     
     userInfo.post()
     user.post()        
     
     self.redirect('/settings/')
Exemple #2
0
 def post(self):
     
     errMsg = {}
     errMsg['email'] = None
     errMsg['password'] = None
     errMsg['repassword'] = None
     errMsg['nickname'] = None
     
     email    = self.get_argument("email",None)
     p1       = self.get_argument("password",None)
     p2       = self.get_argument("repassword",None)
     nickname = self.get_argument("nickname",None)        
     
     if email is None:
         errMsg['email'] = "Email不能为空"
         return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)
     
     if p1 is None:
         errMsg['password'] = "******"
         return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)
     
     if p2 is None:
         errMsg['repassword'] = "******"
         return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)
     
     if p1 != p2:
         errMsg['password'] = "******"
         return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)
     
     if nickname is None:
         errMsg['nickname'] = "呢称不能为空"
         return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)
     
     user = User()
     
     key = hashlib.md5(email).hexdigest()
     user_data = user.get(key)
     
     if user_data is not None:
         errMsg['email'] = "用户已存在"
         return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)
     else:
         user.key                = key
         user.data['email']      = email
         user.data['password']   = hashlib.md5(p1).hexdigest()
         user.data['nickname']   = nickname
         user.data['createTime'] = time.time()            
         user.post()
         
         return self.redirect('/login/')
     return self.render('register.html',user=self.currentUserInfo(),errMsg=errMsg)