当前位置: 首页>>代码示例>>Python>>正文


Python User.gql方法代码示例

本文整理汇总了Python中database.User.gql方法的典型用法代码示例。如果您正苦于以下问题:Python User.gql方法的具体用法?Python User.gql怎么用?Python User.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.User的用法示例。


在下文中一共展示了User.gql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import gql [as 别名]
 def post(self):
     print "Got Venmo payment update"
     print self.request.body
     js = json.loads(self.request.body)
     
     date = js['date_created']
     updateType = js['type']
     data = js['data']
     
     if updateType == "payment.created":
         driverID = data['target']['user']['id']
         passengerID = data['actor']['id']
         driver = User.gql('WHERE venmoID=' + driverID).get()
         passenger = User.gql('WHERE venmoID=' + passengerID).get()
         
         payment = Payment(type="Venmo", dateCreated=date, lastUpdate=date, status=data['status'],
                           driver=driver, passenger=passenger, apiID=data['id'], 
                           amount=data['amount'], note=data['note'])
         payment.put()
         
         # send channel updates to each
         channel.send_message(str(driver.key().id()), "{}");
         channel.send_message(str(passenger.key().id()), "{}");
     elif updateType == "payment.updated":
         status = data['status']
         payment = Payment.gql("WHERE apiID=" + data['id'])
         payment.status = status
         payment.lastUpdated = date # need to check that this is working properly
         
         # add in logic for payment processing
         # check the status and update user/ride info accordingly
         self.processPayment(data, status, payment)
         payment.put()
开发者ID:Nicholasjoseph1994,项目名称:College-Carpool,代码行数:35,代码来源:VenmoWebhook.py

示例2: recoverUsernameUsingEmail

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import gql [as 别名]
 def recoverUsernameUsingEmail(self, email):
     sender_address = "[email protected]"
     user = User.gql("WHERE email=:email", email=email).get()
     subject = "College Carpool Username Recovery"
     body = "Your College Carpool Username is: %s" % (user.username)
     print body
     mail.send_mail(sender_address, email, subject, body)
开发者ID:Nicholasjoseph1994,项目名称:College-Carpool,代码行数:9,代码来源:PasswordRecovery.py

示例3: post

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import gql [as 别名]
    def post(self):
        if "recoverUsername" in self.request.POST:
            try:
                email = self.request.get('email')
                self.recoverUsernameUsingEmail(email)
                self.render('recover.html', color="green", status="Sent recovery email to %s :)" % (email))
            except:
                self.render('recover.html', color="red", status="Could not send email to %s :("  % (email))
        elif "recoverPassword" in self.request.POST:
            try:
                username = self.request.get('username')
                email = ""
                user = None
                if username:
                    print username
                    user = User.gql("WHERE username=:username", username=username).get()
                    email = user.email
                else:
                    email = self.request.get('email')
                    user = User.gql("WHERE email=:email", email=email).get()
                
                salt = validation.make_salt(25)
                link = "http://%s/recover?userID=%s&code=%s" % (self.request.host, user.key().id(), salt)

                user.recoveryCode = salt
                user.put()
                
                self.sendPasswordRecoveryEmail(email, user, link)    
                self.render('recover.html', color="green", 
                            status="Sent recovery email to a %s account :)" % (email.split("@")[1]))
            except:
                self.render('recover.html', color="red", status="Could not send email :(")
        elif "resetPassword" in self.request.POST:
            userID = self.request.get('userID')
            user = User.get_by_id(int(userID))
            
            newPass = self.request.get('newPassword')
            passwordSuccess, passwordError = "", ""
            if newPass == self.request.get('verifyNewPassword'):
                user.passHash = validation.make_pw_hash(user.username, newPass)
                user.recoveryCode = None
                user.put()
                passwordSuccess = "Password Changed Successfully!"
                self.render('recover.html', color="green", status=passwordSuccess)
            else:
                passwordError = "New passwords are not the same"
                self.render('recover.html', color="red", status=passwordError, recover=True, userID=userID)
开发者ID:Nicholasjoseph1994,项目名称:College-Carpool,代码行数:49,代码来源:PasswordRecovery.py


注:本文中的database.User.gql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。