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


Python User.name方法代码示例

本文整理汇总了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)
开发者ID:bluemania,项目名称:Code,代码行数:9,代码来源:Game.py

示例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
开发者ID:scorphus,项目名称:generator-flask-app,代码行数:35,代码来源:_auth.py

示例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)
开发者ID:uisky,项目名称:flask-fish,代码行数:30,代码来源:views.py

示例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
开发者ID:aacoppa,项目名称:inglorious-gangsters,代码行数:54,代码来源:Populator.py

示例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 
开发者ID:av8ramit,项目名称:excelerate,代码行数:7,代码来源:Commands.py


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