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


Python UserService.set_password方法代码示例

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


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

示例1: main

# 需要导入模块: from ziggurat_foundations.models.services.user import UserService [as 别名]
# 或者: from ziggurat_foundations.models.services.user.UserService import set_password [as 别名]
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, name="testscaffold", options=options)

    engine = get_engine(settings)

    session_factory = get_session_factory(engine)
    dbsession = get_tm_session(session_factory, transaction.manager)

    with transaction.manager:
        user = User(user_name="admin", email="[email protected]")
        UserService.set_password(user, "admin")
        admin_object = Group(group_name="Administrators")
        group_permission = GroupPermission(perm_name="root_administration")
        dbsession.add(admin_object)
        admin_object.permissions.append(group_permission)
        admin_object.users.append(user)

        test_group = Group(group_name="Other group")
        dbsession.add(test_group)
        for x in range(1, 25):
            user = User(user_name="test{}".format(x), email="foo{}@localhost".format(x))
            UserService.set_password(user, "test")
            test_group.users.append(user)
开发者ID:ergo,项目名称:testscaffold,代码行数:30,代码来源:initializedb.py

示例2: add_user

# 需要导入模块: from ziggurat_foundations.models.services.user import UserService [as 别名]
# 或者: from ziggurat_foundations.models.services.user.UserService import set_password [as 别名]
def add_user(
    db_session,
    user_name="username",
    email="email",
    perms=["root", "alter_users"],
    password="password",
):
    user = User(user_name=user_name, email=email, status=0)
    UserService.set_password(user, password)
    for perm in perms:
        u_perm = UserPermission(perm_name=perm)
        user.user_permissions.append(u_perm)
    db_session.add(user)
    db_session.flush()
    return user
开发者ID:ergo,项目名称:ziggurat_foundations,代码行数:17,代码来源:__init__.py

示例3: set_password

# 需要导入模块: from ziggurat_foundations.models.services.user import UserService [as 别名]
# 或者: from ziggurat_foundations.models.services.user.UserService import set_password [as 别名]
    def set_password(self, raw_password):
        """

        .. deprecated:: 0.8

        :param raw_password:
        :return:
        """
        return UserService.set_password(self, raw_password=raw_password)
开发者ID:stevepiercy,项目名称:ziggurat_foundations,代码行数:11,代码来源:user.py

示例4: test_users_for_perms

# 需要导入模块: from ziggurat_foundations.models.services.user import UserService [as 别名]
# 或者: from ziggurat_foundations.models.services.user.UserService import set_password [as 别名]
 def test_users_for_perms(self, db_session):
     user = User(user_name="aaa", email="aaa", status=0)
     UserService.set_password(user, "password")
     aaa_perm = UserPermission(perm_name="aaa")
     bbb_perm = UserPermission(perm_name="bbb")
     bbb2_perm = UserPermission(perm_name="bbb")
     user.user_permissions.append(aaa_perm)
     user.user_permissions.append(bbb_perm)
     user2 = User(user_name="bbb", email="bbb", status=0)
     UserService.set_password(user2, "password")
     user2.user_permissions.append(bbb2_perm)
     user3 = User(user_name="ccc", email="ccc", status=0)
     UserService.set_password(user3, "password")
     group = add_group(db_session)
     group.users.append(user3)
     db_session.add(user)
     db_session.add(user2)
     db_session.flush()
     users = UserService.users_for_perms(["aaa"], db_session=db_session)
     assert len(users.all()) == 1
     assert users[0].user_name == "aaa"
     users = UserService.users_for_perms(["bbb"], db_session=db_session).all()
     assert len(users) == 2
     assert ["aaa", "bbb"] == sorted([u.user_name for u in users])
     users = UserService.users_for_perms(
         ["aaa", "bbb", "manage_apps"], db_session=db_session
     )
     assert ["aaa", "bbb", "ccc"] == sorted([u.user_name for u in users])
开发者ID:ergo,项目名称:ziggurat_foundations,代码行数:30,代码来源:test_permissions.py


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