當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。