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


Python Session.rollback方法代码示例

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


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

示例1: revoke_perm

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    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,代码行数:12,代码来源:db_1_2_0.py

示例2: _get_or_create_key

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
 def _get_or_create_key(cls, key, prefix, org_key):
     inv_obj = Session.query(cls).filter(cls.cache_key == key).scalar()
     if not inv_obj:
         try:
             inv_obj = CacheInvalidation(key, org_key)
             Session.add(inv_obj)
             Session.commit()
         except Exception:
             log.error(traceback.format_exc())
             Session.rollback()
     return inv_obj
开发者ID:msabramo,项目名称:kallithea,代码行数:13,代码来源:db_1_3_0.py

示例3: grant_perm

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    def grant_perm(cls, users_group_id, perm):
        if not isinstance(perm, Permission):
            raise Exception('perm needs to be an instance of Permission class')

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

示例4: create

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    def create(cls, form_data):
        try:
            new_users_group = cls()
            for k, v in form_data.items():
                setattr(new_users_group, k, v)

            Session.add(new_users_group)
            Session.commit()
            return new_users_group
        except:
            log.error(traceback.format_exc())
            Session.rollback()
            raise
开发者ID:msabramo,项目名称:kallithea,代码行数:15,代码来源:db_1_2_0.py

示例5: delete

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    def delete(cls, users_group_id):
        try:

            # check if this group is not assigned to repo
            assigned_groups = UserGroupRepoToPerm.query()\
                .filter(UserGroupRepoToPerm.users_group_id ==
                        users_group_id).all()

            if assigned_groups:
                raise UserGroupsAssignedException('RepoGroup assigned to %s' %
                                                   assigned_groups)

            users_group = cls.get(users_group_id, cache=False)
            Session.delete(users_group)
            Session.commit()
        except:
            log.error(traceback.format_exc())
            Session.rollback()
            raise
开发者ID:msabramo,项目名称:kallithea,代码行数:21,代码来源:db_1_2_0.py

示例6: set_invalidate

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    def set_invalidate(cls, key):
        """
        Mark this Cache key for invalidation

        :param key:
        """

        key, _prefix, _org_key = cls._get_key(key)
        inv_objs = Session.query(cls).filter(cls.cache_args == _org_key).all()
        log.debug('marking %s key[s] %s for invalidation' % (len(inv_objs),
                                                             _org_key))
        try:
            for inv_obj in inv_objs:
                if inv_obj:
                    inv_obj.cache_active = False

                Session.add(inv_obj)
            Session.commit()
        except Exception:
            log.error(traceback.format_exc())
            Session.rollback()
开发者ID:msabramo,项目名称:kallithea,代码行数:23,代码来源:db_1_3_0.py

示例7: set_invalidate

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    def set_invalidate(cls, key):
        """
        Mark this Cache key for invalidation

        :param key:
        """

        log.debug('marking %s for invalidation' % key)
        inv_obj = Session.query(cls)\
            .filter(cls.cache_key == key).scalar()
        if inv_obj:
            inv_obj.cache_active = False
        else:
            log.debug('cache key not found in invalidation db -> creating one')
            inv_obj = CacheInvalidation(key)

        try:
            Session.add(inv_obj)
            Session.commit()
        except Exception:
            log.error(traceback.format_exc())
            Session.rollback()
开发者ID:msabramo,项目名称:kallithea,代码行数:24,代码来源:db_1_2_0.py

示例8: update

# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import rollback [as 别名]
    def update(cls, users_group_id, form_data):

        try:
            users_group = cls.get(users_group_id, cache=False)

            for k, v in form_data.items():
                if k == 'users_group_members':
                    users_group.members = []
                    Session.flush()
                    members_list = []
                    if v:
                        v = [v] if isinstance(v, basestring) else v
                        for u_id in set(v):
                            member = UserGroupMember(users_group_id, u_id)
                            members_list.append(member)
                    setattr(users_group, 'members', members_list)
                setattr(users_group, k, v)

            Session.add(users_group)
            Session.commit()
        except:
            log.error(traceback.format_exc())
            Session.rollback()
            raise
开发者ID:msabramo,项目名称:kallithea,代码行数:26,代码来源:db_1_2_0.py


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