本文整理汇总了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()
示例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
示例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()
示例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
示例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
示例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()
示例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()
示例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