本文整理汇总了Python中kallithea.model.meta.Session.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Session.delete方法的具体用法?Python Session.delete怎么用?Python Session.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kallithea.model.meta.Session
的用法示例。
在下文中一共展示了Session.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_test_settings
# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import delete [as 别名]
def set_test_settings():
"""Restore settings after test is over."""
# Save settings.
settings_snapshot = [
(s.app_settings_name, s.app_settings_value, s.app_settings_type)
for s in Setting.query().all()]
yield _set_settings
# Restore settings.
session = Session()
keys = frozenset(k for (k, v, t) in settings_snapshot)
for s in Setting.query().all():
if s.app_settings_name not in keys:
session.delete(s)
for k, v, t in settings_snapshot:
if t == 'list' and hasattr(v, '__iter__'):
v = ','.join(v) # Quirk: must format list value manually.
Setting.create_or_update(k, v, t)
session.commit()
示例2: delete
# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import delete [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
示例3: delete
# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import delete [as 别名]
def delete(cls, id_):
obj = cls.query().get(id_)
Session.delete(obj)