本文整理汇总了Python中user.User.last_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.last_name方法的具体用法?Python User.last_name怎么用?Python User.last_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.last_name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import last_name [as 别名]
def add_user():
response = create_generic_response_dict()
if request.method == 'POST' or request.method == 'PUT':
# create user
data = request.form
username = data.get('username',None)
password = data.get('password', None)
if username == None or password == None:
# Let the caller know that username or password can not be empty.
logger.info("Caught add_user request["+request.method+"] with insufficient parameters.")
response['error'] = True
response['message'] = 'Username and password can not be empty'
return jsonify(response)
first_name = data.get('firstname','')
last_name = data.get('lastname','')
email = data.get('email','')
# Create user and assign values
user = User(username, password)
user.first_name = first_name
user.last_name = last_name
user.email = email
if user.validate():
datastore = UserStore()
if not datastore.has_user(user) and not datastore.is_username_taken(user.username):
# if doesn't exist then register user
datastore.save_user(user);
# success
logger.info('Caught add_user request['+request.method+'] - User['+user.username+'] was successfully registered.')
response['message'] = 'User was successfully created.'
response['data'] = user.get_values_as_dict()
else:
# failed because it already exists?
logger.info('Caught add_user request['+request.method+'] - User['+user.username+'] was already registered.')
response['error'] = True
response['message'] = 'User was not successfully created. User information is not unique.'
pass
else:
# Not valid
logger.info('Caught add_user request['+request.method+'] - User['+user.username+'] did not validate correctly.')
response['error'] = True
response['message'] = 'User information was not validated correctly'
response['data'] = user.get_errors()
pass
return jsonify(response)
示例2: get_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import last_name [as 别名]
def get_user(self, username):
cursor = self.__get_cursor__()
query = "SELECT * FROM user_table WHERE username='{0}' and active=1".format(username)
cursor.execute(query)
list = cursor.fetchall()
if len(list) > 0:
data = list[0]
# Tuple in order of columns
# id, first_name, last_name, email, username, password, creation_date, active
user = User(data[4], data[5])
user.first_name = data[1]
user.last_name = data[2]
user.email = data[3]
user._id = data[0]
return user
else:
return None
示例3: register_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import last_name [as 别名]
def register_user(self, name, last_name, city, age, email, login, password, secret_word):
# if email in self.emails:
# print('This email is already used')
# return
if login in self.users:
print('This login is already taken')
return
# self.emails.add(email)
new_user = User()
new_user.name = name
new_user.last_name = last_name
new_user.city = city
new_user.age = age
new_user.email = email
new_user.login = login
new_user.password = password
new_user.secret_word = secret_word
self.users[login] = new_user
print('registration successful')
示例4: sign_up_clicked
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import last_name [as 别名]
def sign_up_clicked(self):
self.line_edits = []
self.line_edits.append(self.lineEditPassword)
self.line_edits.append(self.lineEditName)
self.line_edits.append(self.lineEditLastName)
self.line_edits.append(self.lineEditAge)
self.line_edits.append(self.lineEditWeight)
self.line_edits.append(self.lineEditUsername)
self.line_edits.append(self.lineEditPassword)
self.label_validation.setText("")
for line_edit in self.line_edits:
if line_edit.text() == "":
self.label_validationSign.setText("All fields required.")
return
new_user = User()
new_user.first_name = str(self.lineEditName.text())
new_user.last_name = str(self.lineEditLastName.text())
new_user.age = int(self.lineEditAge.text())
new_user.weight = int(self.lineEditWeight.text())
new_user.user_name = str(self.lineEditUsername.text())
new_user.password = str(self.lineEditPassword.text())
error = database.insert_user(new_user)
if error:
if isinstance(error, MySQLdb.IntegrityError):
if "Duplicate entry" in error.args[1]:
#If we have a duplicate entry
self.label_validation.setText("Sorry that username is already taken.")
else:
#If we successfully signed up we should set a message on log in page
self.stackedWidget.setCurrentIndex(0)
self.label_validationSign.setText("Sign up SUCCESSFUL!")
示例5: test_invalid_last_name
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import last_name [as 别名]
def test_invalid_last_name(self):
last_name = ""
user = User()
with self.assertRaises(ValueError):
user.last_name = last_name
示例6: test_valid_last_name
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import last_name [as 别名]
def test_valid_last_name(self):
last_name = "LastName"
user = User()
user.last_name = last_name
self.assertEqual(last_name, user.last_name)