本文整理汇总了Python中lib.User.User类的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_message
def create_message(from_user_email,
to_user_email,
message_subject,
message_body):
"""
Add a new message to the datastore
"""
from_user_ref = User.get_by_key_name(from_user_email)
to_user_ref = User.get_by_key_name(to_user_email)
new_message = Message(fromUser=from_user_ref,
toUser=to_user_ref,
subject=message_subject,
body=message_body)
new_message.put()
示例2: admin
def admin():
status = ["default", "none"]
if Configuration.loginRequired():
if not current_user.is_authenticated():
return render_template('login.html', status=status)
else:
return render_template('admin.html', status=status, stats=adminStats())
else:
person = User.get("_dummy_")
login_user(person)
return render_template('admin.html', status=status, stats=adminStats())
示例3: login_check
def login_check():
# validate username and password
username = request.form.get('username')
password = request.form.get('password')
person = User.get(username)
try:
if person and pbkdf2_sha256.verify(password, person.password):
login_user(person)
return render_template('admin.html', status=["logged_in", "success"], stats=adminStats())
else:
return render_template('login.html', status=["wrong_combination", "warning"])
except:
return render_template('login.html', status=["outdated_database", "error"])
示例4: login_check
def login_check():
# validate username and password
username = request.form.get('username')
password = request.form.get('password')
person = User.get(username)
try:
if person and pbkdf2_sha256.verify(password, person.password):
login_user(person)
return render_template('admin.html', status="logged_in", **adminInfo())
else:
return render_template('login.html', status="wrong_user_pass")
except:
return render_template('login.html', status="outdated_database")
示例5: admin
def admin():
if Configuration.loginRequired():
if not current_user.is_authenticated():
return render_template('login.html')
else:
person = User.get("_dummy_")
login_user(person)
output = None
if os.path.isfile(Configuration.getUpdateLogFile()):
with open(Configuration.getUpdateLogFile()) as updateFile:
separator="==========================\n"
output=updateFile.read().split(separator)[-2:]
output=separator+separator.join(output)
return render_template('admin.html', status="default", stats=adminStats(), updateOutput=filterUpdateField(output))
示例6: login_check
def login_check(self):
# validate username and password
username = request.form.get('username')
password = request.form.get('password')
person = User.get(username, self.auth_handler)
try:
if person and person.authenticate(password):
login_user(person)
return render_template('admin.html', status="logged_in", **self.adminInfo())
else:
return render_template('login.html', status="wrong_user_pass")
except Exception as e:
print(e)
return render_template('login.html', status="outdated_database")
示例7: load_user
def load_user(id):
return User.get(id)
示例8: load_user
def load_user(self, id):
return User.get(id, self.auth_handler)