示例#1
0
 def sellerRegist_view(self):
     if self.request.method == 'POST':
         form = Form(self.request,
                     schema=RegistForm, defaults={},
                     state=State(request=self.request))
         if form.validate():
             request = self.request
             sName = form.data['sname']
             pwd = form.data['pwd']
             tel = form.data['tel']
             email = form.data['email']
             address = form.data['address']
             sDetail = form.data['sDetail']
             params = {'sName': sName, 'pwd': encrypt(pwd), 'tel': tel, 'email': email, 'address': address,
                       'sDetail': sDetail}
             result = Seller.sellerRegist(self.mongodb, **params)
             if result is not None:
                 param = {'sName': sName, 'pwd': encrypt(pwd)}
                 user = Seller.sellerlogin(self.mongodb, **param)
                 self.request.session['user'] = user
                 headers = remember(self.request, ['id'])
                 return HTTPFound('/seller/show', headers=headers)
             else:
                 return {'form': form}
     return {'regist': 'test'}
示例#2
0
 def sellerlogin_view(self):
     if self.request.method == 'POST':
         form = Form(self.request,
                     schema=LoginForm, defaults={},
                     state=State(request=self.request))
         vcode = self.request.POST['validateCode']
         _csrf = self.request.POST['_csrf']
         ret = requests.get("http://open.weidianbao.com/validate/code/json?vcode=" + vcode + "&token=" + _csrf)
         retJson = json.loads(ret.content)
         if not retJson['success']:
             form.errors.update({"hint": u'验证码不正确!'})
             return {"form": form}
         if form.validate():
             sName = form.data['sname']
             pwd = form.data['pwd']
             params = {'sName': sName, 'pwd': encrypt(pwd)}
             result = Seller.sellerlogin(self.mongodb, **params)
             print result
             if result is not None:
                 self.request.session['user'] = result
                 headers = remember(self.request, result['id'])
                 return HTTPFound('/seller/show', headers=headers)
     return {'form': 'beiju'}