本文整理汇总了Python中model.User.gql方法的典型用法代码示例。如果您正苦于以下问题:Python User.gql方法的具体用法?Python User.gql怎么用?Python User.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.gql方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def post(self):
email = self.session.get(EMAIL_KEY)
users = User.gql('WHERE email = :1', email)
template_params={
}
if (users.count(1) == 1):
word = ''
random = Random()
for i in range(1,8):
word += random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
user = users.get()
user.password = word
m = hashlib.md5()
encodedString = word.encode('ascii', errors='replace')
m.update(encodedString)
user.passwordHash = str(m.hexdigest())
user.put()
template_values = {
"password":word
}
messageTemplate = jinja_environment.get_template('templates/userForms/changePassMail.html')
message = mail.EmailMessage(sender="Diet Futar <[email protected]>")
message.subject="Diet-futar, uj jelszo"
message.to = email
message.html = messageTemplate.render(template_values)
message.send()
template_params[EMAIL_KEY] = email
template = jinja_environment.get_template('templates/userForms/changePassSuccess.html')
self.printPage("Uj jelszo", template.render(template_params), True, True)
示例2: test_remove
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def test_remove(self, cubmail):
print "removing "+cubmail
users = User.gql("WHERE cubmail = :1", cubmail)
myclass = users.get()
try:
db.delete(myclass)
except (Exception):
print "can't find "+cubmail+"\n"
示例3: _delete_all
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def _delete_all(self):
for base in (Competition, UserComp, Scores, Comment):
for item in base.query():
item.key.delete()
for photo in Photo.query():
delete_blob(photo.blob)
photo.key.delete()
for user in User.gql('WHERE username != :1', 'test'):
user.key.delete()
示例4: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def get(self):
email = self.session.get(EMAIL_KEY)
users = User.gql('WHERE email = :1', email)
template_params={
}
if (users.count(1) == 1):
template_params[EMAIL_KEY] = email
template = jinja_environment.get_template('templates/userForms/changePass.html')
self.printPage("Uj jelszo", template.render(template_params), True, True)
示例5: IsUsernameAvailable
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def IsUsernameAvailable(self,request):
username = request.get("username")
userid = request.get("userid")
user = User.gql('WHERE username = :1',username).get()
if user:
if str(user.key()) == userid:
return "True"
else:
return "Invalid"
else:
return "True"
示例6: IsEmailAvailable
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def IsEmailAvailable(self,request):
email = request.get("email")
userid = request.get("userid")
user = User.gql('WHERE email = :1',email).get()
if user:
if str(user.key()) == userid:
return "True"
else:
return "Invalid"
else:
return "True"
示例7: getSalt
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def getSalt(email):
print 'Content-Type: text/plain;charset=UTF-8'
print ''
logging.debug('email: ' + email)
user = User.gql('WHERE email = :1', email).get()
if user is not None:
salt = user.password_salt
else:
#send back a dummy salt
salt = User.generate_salt()
print salt
示例8: doLogin
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def doLogin(args):
user = None
login_info = args.split(',',2)
try:
email_address = login_info[0]
password_hash = login_info[1]
user = User.gql('WHERE email_address = :1 AND password_hash = :2', email_address, password_hash).get()
except IndexError:
pass
print 'Content-Type: text/plain;charset=UTF-8'
print ''
if user is None:
print '0'
else:
Session().set_user(user)
print '1'
示例9: test_get_key
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def test_get_key(self, cubmail):
result = User.gql("WHERE cubmail = :1", cubmail).get()
return result.key()
示例10: test_exists
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gql [as 别名]
def test_exists(self,cubmail):
return User.gql("WHERE cubmail = :1", cubmail).get()