本文整理汇总了Python中user.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_register
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def do_register():
messages = {}
user_data = {
'display' : request.form.get('display'),
'username' : request.form.get('username'),
'password' : request.form.get('password'),
'confirm' : request.form.get('confirm'),
'email' : request.form.get('email')
}
user = User.get(user_data['username'])
if user_data['password'] != user_data['confirm']:
messages['error'] = errors.get("pass_match")
elif display_taken(user_data['display']):
messages['error'] = errors.get("display_in_use")
elif user and user.check_password(user_data['password']):
login_user(user, force=True)
elif user:
messages['error'] = errors.get("user_in_use")
else:
add_user_to_db(user_data)
user = User.get(user_data['username'])
login_user(user, force=True)
user.send_activation_email()
return messages
示例2: user_start_page
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def user_start_page(udid):
user = User.get(udid)
if not user:
User.new(udid)
user = User.get(udid)
ret = {}
ret['action'] = 'get_start_page'
ret['page'] = user.page
return jsonify(ret)
示例3: DoRemoveStar
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def DoRemoveStar():
fav = Favorite.get_by_key_name(map_key.name(), parent=user_key)
if fav:
user = User.get(user_key)
user.favourite_count -= 1
user.put()
fav.delete()
示例4: post_feedback
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def post_feedback(udid):
user = User.get(udid)
if not user:
User.new(udid)
user = User.get(udid)
feedback = request.args.get('feedback', '')
ret = {}
ret['udid'] = user.udid
ret['feedback'] = feedback or '未反馈'
ret['action'] = 'feedback'
ret['r'] = 1
if feedback:
ret['r'] = 0
return jsonify(ret)
示例5: login_post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def login_post():
user = User.get(request.form["text-username"])
if user and user.password == request.form["text-password"]:
login_user(user)
return redirect(url_for("home"))
else:
return login(message="Wrong username or password!")
示例6: assign
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def assign():
if not current_user.is_admin():
return 'Not Authorized', 500
dataset = request.args.get('dataset')
batch = int(request.args.get('batch'))
user = User.get(request.args.get('user'))
with codecs.open(os.path.join(DATA_DIR, dataset+'.json'), 'r', 'utf-8') as f:
lines = f.readlines()
dic = json.loads(lines[batch])
dic['assignedTo'].append(user.get_id())
userDict = user.load()
if dataset not in userDict:
userDict[dataset] = {}
assert str(batch-1) not in userDict[dataset] and str(batch+1) not in userDict[dataset]
userDict[dataset][str(batch)] = dic
user.save(userDict)
lines[batch] = json.dumps(dic) + '\n'
with codecs.open(os.path.join(DATA_DIR, dataset+'.json'), 'w', 'utf-8') as f:
for line in lines:
f.write(line)
with codecs.open(os.path.join(DIRECTORY, 'metaData.json'), 'r', 'utf-8') as f:
meta = json.loads(f.read())
meta['assignments'][dataset][str(batch)] = username
with codecs.open(os.path.join(DIRECTORY, 'metaData.json'), 'w', 'utf-8') as f:
f.write(json.dumps(meta))
return 'OK',200
示例7: get_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def get_user(user_id):
if CACHE.get(user_id):
user = CACHE.get(user_id)
else:
user = User.get(user_id)
CACHE[user_id] = user
return user
示例8: load_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def load_user(userid):
if userid not in mc_challenge_mgr.users:
print ">>>>> load_user(%s) -> users = %r... reloading users" % (userid, mc_challenge_mgr.users)
load_users(mc_challenge_mgr)
u = User.get(mc_challenge_mgr.users, userid)
if u is None:
logout_impl()
示例9: DoAddStar
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def DoAddStar():
fav = Favorite.get_by_key_name(map_key.name(), parent=user_key)
if not fav:
user = User.get(user_key)
user.favourite_count += 1
fav = Favorite(key_name=map_key.name(), parent=user, map_id=self.map_id)
db.put(user)
db.put(fav)
示例10: DoUpdateUser
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def DoUpdateUser(old_bar, new_bar, change_rated_count):
user = User.get(self.user.key())
if old_bar: user.rating_histogram[old_bar] -= abs(delta)/delta
if new_bar: user.rating_histogram[new_bar] += abs(delta)/delta
user.ratings += delta
if change_rated_count:
user.rated_map_count += delta
user.put()
示例11: find_in_area
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def find_in_area(cls, area, limit=20, user_id=None):
query = Location.all().order("-created")
if user_id != None:
user = User.get(long(user_id))
query.filter("user_id =", user_id)
return Location.bounding_box_fetch(query,
geotypes.Box(area[0], area[1], area[2], area[3]),
max_results=limit)
示例12: to_dict
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def to_dict(self):
''' Returns a hash of a booking in the database '''
data = {}
place = Place.get(Place.id == self.place)
user = User.get(User.id == self.user)
data['place_id'] = place.id
data['user_id'] = user.id
data['is_validated'] = self.is_validated
data['date_start'] = self.date_start.strftime("%Y/%m/%d %H:%M:%S")
data['number_nights'] = self.number_nights
return super(PlaceBook, self).to_dict(self, data)
示例13: do_activate
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def do_activate(payload):
s = URLSafeSerializer(app.config['SECRET_KEY'])
try:
username = s.loads(payload)
except BadSignature:
abort(404)
user = User.get(username)
if not user or user.is_active():
abort(404)
user.set_active()
flash('Account activated')
示例14: delete_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def delete_user():
item = self.ui.table_user.currentItem()
if item is None:
return
idx = self.ui.table_user.currentIndex()
name = item.text(0)
user = User.get(name)
if isinstance(user, PersonUser):
print('Cannot delete Person User:', name)
return
user.stop = True
User.users.pop(name) # Let gc do its job...
self.ui.table_user.takeTopLevelItem(idx.row())
示例15: login
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def login():
if request.method == 'GET':
return render_template('_login.html')
r = request.json
if r is not None:
user = User.get(r.get('username'))
print 'login -> <%s>' % user
if user is not None and user.authenticate(r.get('password')):
login_user(user)
return json.dumps({})
abort(500)