当前位置: 首页>>代码示例>>Python>>正文


Python User.username方法代码示例

本文整理汇总了Python中model.user.User.username方法的典型用法代码示例。如果您正苦于以下问题:Python User.username方法的具体用法?Python User.username怎么用?Python User.username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.user.User的用法示例。


在下文中一共展示了User.username方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_account

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import username [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.')
开发者ID:Sonictherocketman,项目名称:Microblogger,代码行数:37,代码来源:webserver.py

示例2: test_remote_username

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import username [as 别名]
 def test_remote_username(self):
     username = 'spam'
     user = User(remote_url='http://microblog.brianschrader.com/feed')
     try:
         # Should fail.
         user.username = username
         self.fail('Setting a remote user should be forbidden.')
     except:
         pass
开发者ID:Sonictherocketman,项目名称:Microblogger,代码行数:11,代码来源:user_test.py

示例3: test_local_username

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import username [as 别名]
 def test_local_username(self):
     username = 'john.cleese'
     user = User(local_url='user/feed.xml')
     try:
         user.username = username
     except Exception as e:
         print e
         self.fail('Setting local user username failed.')
     self.assertEqual(user.username, username)
开发者ID:Sonictherocketman,项目名称:Microblogger,代码行数:11,代码来源:user_test.py

示例4: test_cached_username

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import username [as 别名]
 def test_cached_username(self):
     username = 'graham.chapman'
     user = User(entries={ 'username': username })
     username = 'terry.gilliam'
     try:
         user.username = username
     except Exception as e:
         print e
         self.fail('Setting cached user username failed.')
     self.assertEqual(user.username, username)
开发者ID:Sonictherocketman,项目名称:Microblogger,代码行数:12,代码来源:user_test.py


注:本文中的model.user.User.username方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。