本文整理汇总了Python中model.user.User.language方法的典型用法代码示例。如果您正苦于以下问题:Python User.language方法的具体用法?Python User.language怎么用?Python User.language使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.language方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_account
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import language [as 别名]
def post_account():
# Flask apparently throws 400 errors if POST form data isn't present.
# Full name
user_id = session['user_id']
location = settings.get_user(user_id)['feed_location']
user = User(local_url=location)
if request.form.get('full_name_changed') == 'true':
user.full_name = request.form['full_name']
# Username
if request.form.get('username_changed') == 'true':
username= request.form['username']
if len(username) > 0:
user.username = username
# Bio
if request.form.get('bio_changed') == 'true':
user.description = request.form['bio']
# Email
if request.form.get('email_changed') == 'true':
email = request.form['email']
user_dict = settings.get_user(user_id)
user_dict['email'] = email
settings.add_user(user_dict)
# Password
if request.form.get('password_changed') == 'true':
password = request.form['password']
password_confirm = request.form['password_confirm']
if password == password_confirm:
user_dict = settings.get_user(user_id)
user_dict['pwd_hash'] = generate_password_hash(password)
settings.add_user(user_dict)
# Language
if request.form.get('language_changed') == 'true':
user.language = request.form['language']
return render_template('account.html', user=user, error='Your settings have been saved.')
示例2: test_remote_language
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import language [as 别名]
def test_remote_language(self):
language = 'en'
user = User(remote_url='http://microblog.brianschrader.com/feed')
try:
# should fail.
user.language = language
self.fail('setting a remote user should be forbidden.')
except Exception as e:
pass
示例3: test_local_language
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import language [as 别名]
def test_local_language(self):
language = 'en'
user = User(local_url='user/feed.xml')
try:
user.language = language
except Exception as e:
print e
self.fail('Setting local user language failed.')
self.assertEqual(user.language, language)
示例4: test_cached_language
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import language [as 别名]
def test_cached_language(self):
language = 'en'
user = User(entries={ 'language': language })
language = 'http://example.net'
try:
user.language = language
except Exception as e:
print e
self.fail('Setting cached language failed.')
self.assertEqual(user.language, language)