本文整理汇总了Python中User.name方法的典型用法代码示例。如果您正苦于以下问题:Python User.name方法的具体用法?Python User.name怎么用?Python User.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_players
# 需要导入模块: import User [as 别名]
# 或者: from User import name [as 别名]
def setup_players(self):
# ask how many players
player_count = int(raw_input("How many players?: "))
for count in range(player_count):
temp_user_assign = User()
temp_user_assign.name = "Player " + str(count + 1)
self.users.append(temp_user_assign)
示例2: login
# 需要导入模块: import User [as 别名]
# 或者: from User import name [as 别名]
def login(provider_name):
response = make_response()
result = current_app.authomatic.login(
WerkzeugAdapter(request, response), provider_name
)
if result:
if result.user:
first_login = False
result.user.update()
user = User.objects(provider=provider_name, user_id=result.user.id).first()
if user is None:
user = User(
username=result.user.username,
email=result.user.email,
name=result.user.name,
user_id=result.user.id,
provider=provider_name
)
user.save()
first_login = True
else:
user.name = result.user.name
user.email = result.user.email
user.save()
session['user_id'] = user.user_id
return redirect_next()
flash_error('Authentication failed')
return redirect(url_for('auth.login_page', next=request.path))
return response
示例3: register
# 需要导入模块: import User [as 别名]
# 或者: from User import name [as 别名]
def register():
def check():
email_exists = User.query.filter(db.func.lower(User.email) == form.email.data.lower()).first()
if email_exists:
flash('Пользователь с такой электронной почтой уже зарегистрирован.', 'danger')
return False
return True
user = User()
form = forms.RegisterForm(obj=user)
if form.validate_on_submit() and check():
if form.password.data != form.password2.data:
flash('Введённые пароли не совпадают.')
else:
user.email = form.email.data
user.name = form.name.data
user.password_hash = User.hash_password(form.password.data)
user.roles = 0
db.session.add(user)
db.session.commit()
return render_template('users/after_register.html', email=user.email)
flash_errors(form)
return render_template('users/register.html', form=form)
示例4: populate_database
# 需要导入模块: import User [as 别名]
# 或者: from User import name [as 别名]
def populate_database():
"""
Returns a list of College objects to be stored in the database
Then they can be reconstructed by called
colleges = db_load_colleges()
"""
database_schools = []
n = 0
cols = []
cols_with_size = get_sizes()
while n < len(colleges_with_sat):
c = C(colleges_with_sat[n], colleges_with_sat[n+1], colleges_with_sat[n+2], colleges_with_sat[n+3], colleges_with_sat[n+4])
cols.append(c)
n+=5
for i in range(0, len(colleges)):
name = colleges[i]
if False: #db_college_exists(name):
continue
sats = {}
size = 0
tuition = 0
address = ""
zipcode = 0
matched = False
for c in cols:
if levenshtein(c.name, name) < 3:
matched = True
sats['math'] = c.math_range
sats['reading'] = c.read_range
if not matched:
sats = None
for c in cols_with_size:
#print c[0]
if levenshtein(c[0], name) < 3:
size = c[1]
tuition = c[2]
address = c[3]
zipcode = c[4]
#print c
break
college = College(name, "", i, sats, size, tuition, address, zipcode)
#print college
database_schools.append(college)
#college.print_college()
user = User()
user.name = "Aaron"
user.sats = {"math" : 800, "reading" : 800}
#print college.find_location()
#print college.get_difficulty()
return database_schools
示例5: load_user
# 需要导入模块: import User [as 别名]
# 或者: from User import name [as 别名]
def load_user(name, filename, classname): #load user function creates a user object and recreates user data
u = User(name, classname) #instantiate a user object with parameters username and user's classname
u.name = name #assign user object 'name' attribute the username
u.recreate_user(filename) #call user object method recreate_user() from User.py
return u #return recreated user object - used in Console.py