本文整理汇总了Python中user.User.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python User.fetch方法的具体用法?Python User.fetch怎么用?Python User.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.fetch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_password
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def add_password(username):
password = str(request.form['password'])
confirm_password = str(request.form['confirm_password'])
existing_password = str(request.form['existing_password'])
params = {
'username': username,
'password': password,
}
user = User.fetch(db, username)
error = None
if not user.getPassword(existing_password):
error = "The existing password you entered was not found."
if error is None and password != confirm_password:
error = "The password you entered to confirm was not the same as entered originally."
if error:
return render_template('private/unknown.htm', error=error, **params)
log_event('add-password', {
'username': username,
})
user.addPasswordHash(createHash(password))
params = {
'username': username,
'message': 'Your new password is now available.'
}
return render_template('private/index.htm', **params)
示例2: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def get(self, uid):
try:
user = yield User.fetch(uid)
except KeyError:
self.clear_current_user()
self.send_error(httplib.NOT_FOUND)
return
self.write(self.application.user_representation(user))
示例3: user_get_sites
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def user_get_sites(username):
password = str(request.form['password'])
user = User.fetch(db, username)
sites = user and user.getSites(password)
log_event('get-sites', {
'username': username,
'found': (sites is not None)
})
if sites is None:
return '{"result": false, "sites": []}'
else:
return json.dumps({"result": True, "sites": sites})
示例4: signup
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def signup():
hash = str(request.form['hash'])
site = str(request.form['site'])
username = str(request.form['username'])
error = None
if User.fetch(db, username):
error = "The username you selected is taken."
elif not re.match(r'^[a-z]+$', username):
error = 'Your username can only be made of lowercase letters'
elif username in config.reserved:
error = 'Sorry, the username you have selected is reserved'
if error:
params = {
'hash': hash,
'site': site,
'new_username': username,
'error': error
}
return render_template('public/password.htm', **params)
else:
db.hset('signups', username, json.dumps({
'hash': hash,
'site': site
}))
log_event('request-signup', {
'username': username
})
return redirect((config.paypal_url + '?cmd=_xclick' + \
'&item_name=Signup+for+password.ly:+{username}' + \
'&item_number={username}&amount={price}&business={email}' + \
'&custom={username}' + \
'¤cy_code=USD' + \
'¬ify_url={ipn}' + \
'&cancel_return=http://password.ly/paypal/cancel' + \
'&return=http://password.ly/{username}').format(
username=username,
email=config.paypal_email,
price=config.price,
ipn=config.ipn_url
))
示例5: user_sync
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def user_sync(username):
password = str(request.form['password'])
user = User.fetch(db, username)
user_password = user.getPassword(password)
if not user_password:
log_event('sync-fail', {'username': username})
return '{"result": false, "sites": {}}'
# Sync theirs into ours (where we don't have anything)
theirs = json.loads(request.form['sites'])
ours = user_password.getAllComments()
for site, comment in theirs.items():
if not site in ours:
user_password.setSite(site, comment)
ours[site] = comment
log_event('sync', {'username': username})
return json.dumps({"result": True, "sites": ours})