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


Python meta.Session类代码示例

本文整理汇总了Python中kallithea.model.meta.Session的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setup_method

    def setup_method(self, method):
        Session.remove()
        u1 = UserModel().create_or_update(username=u'u1',
                                        password=u'qweqwe',
                                        email=u'[email protected]',
                                        firstname=u'u1', lastname=u'u1')
        Session().commit()
        self.u1 = u1.user_id

        u2 = UserModel().create_or_update(username=u'u2',
                                        password=u'qweqwe',
                                        email=u'[email protected]',
                                        firstname=u'u2', lastname=u'u3')
        Session().commit()
        self.u2 = u2.user_id

        u3 = UserModel().create_or_update(username=u'u3',
                                        password=u'qweqwe',
                                        email=u'[email protected]',
                                        firstname=u'u3', lastname=u'u3')
        Session().commit()
        self.u3 = u3.user_id

        self.remove_all_notifications()
        assert [] == Notification.query().all()
        assert [] == UserNotification.query().all()
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:26,代码来源:test_notifications.py

示例2: toggle_following

    def toggle_following(self):
        cur_token = request.POST.get('auth_token')
        token = h.get_token()
        if cur_token == token:

            user_id = request.POST.get('follows_user_id')
            if user_id:
                try:
                    self.scm_model.toggle_following_user(user_id,
                                                self.authuser.user_id)
                    Session.commit()
                    return 'ok'
                except Exception:
                    log.error(traceback.format_exc())
                    raise HTTPBadRequest()

            repo_id = request.POST.get('follows_repo_id')
            if repo_id:
                try:
                    self.scm_model.toggle_following_repo(repo_id,
                                                self.authuser.user_id)
                    Session.commit()
                    return 'ok'
                except Exception:
                    log.error(traceback.format_exc())
                    raise HTTPBadRequest()

        log.debug('token mismatch %s vs %s' % (cur_token, token))
        raise HTTPBadRequest()
开发者ID:msabramo,项目名称:kallithea,代码行数:29,代码来源:journal.py

示例3: test_push_unlocks_repository_git

    def test_push_unlocks_repository_git(self, webserver):
        # enable locking
        fork_name = '%s_fork%s' % (GIT_REPO, _RandomNameSequence().next())
        fixture.create_fork(GIT_REPO, fork_name)
        r = Repository.get_by_repo_name(fork_name)
        r.enable_locking = True
        Session().commit()
        #clone some temp
        DEST = _get_tmp_dir()
        clone_url = webserver.repo_url(fork_name)
        stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)

        #check for lock repo after clone
        r = Repository.get_by_repo_name(fork_name)
        assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id

        #push is ok and repo is now unlocked
        stdout, stderr = _add_files_and_push(webserver, 'git', DEST, clone_url=clone_url)
        _check_proper_git_push(stdout, stderr)

        assert ('remote: Released lock on repo `%s`' % fork_name) in stderr
        #we need to cleanup the Session Here !
        Session.remove()
        r = Repository.get_by_repo_name(fork_name)
        assert r.locked == [None, None]
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:25,代码来源:test_vcs_operations.py

示例4: create

 def create(cls, users_group, repository, permission):
     n = cls()
     n.users_group = users_group
     n.repository = repository
     n.permission = permission
     Session.add(n)
     return n
开发者ID:msabramo,项目名称:kallithea,代码行数:7,代码来源:db_1_3_0.py

示例5: teardown_method

 def teardown_method(self, method):
     if self.r2_id:
         RepoModel().delete(self.r2_id)
     if self.r1_id:
         RepoModel().delete(self.r1_id)
     Session().commit()
     Session.remove()
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:7,代码来源:test_compare.py

示例6: add_user_to_group

 def add_user_to_group(group, user):
     ugm = UserGroupMember()
     ugm.users_group = group
     ugm.user = user
     Session.add(ugm)
     Session.commit()
     return ugm
开发者ID:msabramo,项目名称:kallithea,代码行数:7,代码来源:db_1_2_0.py

示例7: update_lastlogin

    def update_lastlogin(self):
        """Update user lastlogin"""

        self.last_login = datetime.datetime.now()
        Session.add(self)
        Session.commit()
        log.debug('updated user %s lastlogin' % self.username)
开发者ID:msabramo,项目名称:kallithea,代码行数:7,代码来源:db_1_2_0.py

示例8: teardown_method

    def teardown_method(self, method):
        perm = Permission.query().all()
        for p in perm:
            UserModel().revoke_perm(self.u1, p)

        UserModel().delete(self.u1)
        Session().commit()
        Session.remove()
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:8,代码来源:test_users.py

示例9: create_or_update_hook

    def create_or_update_hook(cls, key, val):
        new_ui = cls.get_by_key(key).scalar() or cls()
        new_ui.ui_section = 'hooks'
        new_ui.ui_active = True
        new_ui.ui_key = key
        new_ui.ui_value = val

        Session.add(new_ui)
开发者ID:msabramo,项目名称:kallithea,代码行数:8,代码来源:db_1_3_0.py

示例10: _set_settings

def _set_settings(*kvtseq):
    session = Session()
    for kvt in kvtseq:
        assert len(kvt) in (2, 3)
        k = kvt[0]
        v = kvt[1]
        t = kvt[2] if len(kvt) == 3 else 'unicode'
        Setting.create_or_update(k, v, t)
    session.commit()
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:9,代码来源:conftest.py

示例11: set_valid

    def set_valid(cls, key):
        """
        Mark this cache key as active and currently cached

        :param key:
        """
        inv_obj = cls.get_by_key(key)
        inv_obj.cache_active = True
        Session.add(inv_obj)
        Session.commit()
开发者ID:msabramo,项目名称:kallithea,代码行数:10,代码来源:db_1_3_0.py

示例12: revoke_perm

    def revoke_perm(cls, users_group_id, perm):
        if not isinstance(perm, Permission):
            raise Exception('perm needs to be an instance of Permission class')

        try:
            cls.query().filter(cls.users_group_id == users_group_id) \
                .filter(cls.permission == perm).delete()
            Session.commit()
        except:
            Session.rollback()
开发者ID:msabramo,项目名称:kallithea,代码行数:10,代码来源:db_1_2_0.py

示例13: set_valid

    def set_valid(cls, key):
        """
        Mark this cache key as active and currently cached

        :param key:
        """
        inv_obj = Session.query(CacheInvalidation)\
            .filter(CacheInvalidation.cache_key == key).scalar()
        inv_obj.cache_active = True
        Session.add(inv_obj)
        Session.commit()
开发者ID:msabramo,项目名称:kallithea,代码行数:11,代码来源:db_1_2_0.py

示例14: _destroy_project_tree

def _destroy_project_tree(test_u1_id):
    Session.remove()
    repo_group = RepoGroup.get_by_group_name(group_name='g0')
    for el in reversed(repo_group.recursive_groups_and_repos()):
        if isinstance(el, Repository):
            RepoModel().delete(el)
        elif isinstance(el, RepoGroup):
            RepoGroupModel().delete(el, force_delete=True)

    u = User.get(test_u1_id)
    Session().delete(u)
    Session().commit()
开发者ID:msabramo,项目名称:kallithea,代码行数:12,代码来源:common.py

示例15: teardown_class

    def teardown_class(cls):
        # delete in reversed order, to delete fork destination at first
        for reponame, init_or_fork, groupname in reversed(repos):
            RepoModel().delete(repoids[reponame])

        for reponame, init_or_fork, groupname in reversed(repos):
            if groupname in groupids:
                RepoGroupModel().delete(groupids.pop(groupname),
                                        force_delete=True)

        Session().commit()
        Session.remove()

        rebuild_index(full_index=True) # rebuild fully for subsequent tests
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:14,代码来源:test_search_indexing.py


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