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


Python User.get方法代码示例

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


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

示例1: admin_users_edit_post

# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def admin_users_edit_post():
    payload = get_payload(request)
    user_id = payload.get('user_id')
    if user_id:
        user = User.get(user_id)
        return_value = success('All profile values have been updated.')
    else:
        user = User()
        user.insert()
        return_value = success('User created.')
        if not payload.get('password'):
            return jsonify(failure('You must set a password for new users'))
        if not payload.get('email'):
            return jsonify(failure('You must set an email for new users'))
        if not payload.get('name'):
            return jsonify(failure('You must set a name for new users'))

    for key in payload:
        if key == 'password':
            user.set_password(payload[key])
        elif key != 'user_id':
            setattr(user, key, payload[key])

    g.user.insert()
    safe_commit()

    return jsonify(return_value)
开发者ID:smeggingsmegger,项目名称:flask-cookiecutter,代码行数:29,代码来源:admin.py

示例2: adduser

# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
 def adduser(self, userkey, uname):
     """Add a user to the datastore."""
     #Check for a user with that name
     if User.get(uname) is not None:
         raise RuntimeError("Username in use")
     if User.gql("WHERE googleacct = :1", users.get_current_user()).count() > 0:
         raise RuntimeError("Account in use")
     User.(key_name=uname, userkey=userkey, uname=uname).put()
开发者ID:magisterquis,项目名称:ResistanceGameServer,代码行数:10,代码来源:register.py

示例3: retrieve_user

# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def retrieve_user():
    return_value = success('The user was retrieved.')
    payload = get_payload(request)
    user = User.get(payload.get('id'))

    if not user:
        return_value = failure('That user does not exist.')
    else:
        return_value['user'] = user.to_dict(camel_case=True)
        return_value['user'].pop('password')
        return_value['user'].pop('openid')

    return jsonify(return_value)
开发者ID:smeggingsmegger,项目名称:flask-cookiecutter,代码行数:15,代码来源:admin.py

示例4: update_user

# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def update_user():
    return_value = success('The user was updated.')
    payload = get_payload(request)
    user = User.get(payload.get('id'))

    if not user:
        return_value = failure('That user does not exist.')
    else:
        if payload.get('password'):
            user.set_password(payload.get('password'))
        if payload.get('email'):
            user.email = payload.get('email')
        if payload.get('name'):
            user.name = payload.get('name')

        safe_commit()
        return_value['user'] = user.to_dict(camel_case=True)

    return jsonify(return_value)
开发者ID:smeggingsmegger,项目名称:flask-cookiecutter,代码行数:21,代码来源:admin.py

示例5: admin_users_edit

# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def admin_users_edit(user_id=''):
    user = User.get(user_id)
    return render_template('user.html', user=user)
开发者ID:smeggingsmegger,项目名称:flask-cookiecutter,代码行数:5,代码来源:admin.py


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