本文整理汇总了Python中dmirr.model.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmirr.model.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from dmirr.model import DBSession [as 别名]
# 或者: from dmirr.model.DBSession import delete [as 别名]
def delete(self, user_name=None, *a, **kw):
u = db.query(model.User).filter_by(user_name=user_name).first()
admins = db.query(model.Group).filter_by(group_name='dmirr_admin')\
.all()
_display_name = u.display_name
if not u:
raise HTTPNotFound
_h.protect_user_obj(u)
came_from = url('/user/%s/edit' % u.user_name)
if u.user_name in admins and len(admins) == 1:
flash(_("Can not delete the only site administrator."), 'warning')
redirect(came_from)
confirmed = kw.get('confirmed', None)
if not confirmed:
display_name = u.display_name
action = url('/user/%s/delete' % u.user_name)
return dict(errors={}, display_name=display_name, action=action,
came_from=came_from)
else:
db.delete(u)
transaction.commit()
flash(_("%s and all associated data have been deleted." % \
_display_name), 'info')
redirect(url('/logout_handler'))
示例2: delete
# 需要导入模块: from dmirr.model import DBSession [as 别名]
# 或者: from dmirr.model.DBSession import delete [as 别名]
def delete(self, project_label=None, *a, **kw):
_p = DBSession.query(Project).filter_by(label=project_label).first()
if not _p:
raise HTTPNotFound
_p_label = _p.label
_h.protect_obj(_p)
confirmed = kw.get('confirmed', None)
if not confirmed:
display_name = _p.display_name
action = url('/project/%s/delete' % _p.label)
came_from = url('/project/%s/edit' % _p_label)
return dict(page="project", errors={}, display_name=display_name, action=action, came_from=came_from)
else:
DBSession.delete(_p)
transaction.commit()
flash(_("%s and all associated data have been deleted." % _p.display_name), 'info')
redirect(url('/dashboard'))
示例3: delete
# 需要导入模块: from dmirr.model import DBSession [as 别名]
# 或者: from dmirr.model.DBSession import delete [as 别名]
def delete(self, host_address=None, *a, **kw):
h = DBSession.query(Host).filter_by(address=host_address).first()
if not h:
raise HTTPNotFound
_host_address = h.address
_h.protect_obj(h)
confirmed = kw.get('confirmed', None)
if not confirmed:
display_name = h.address
action = url('/host/%s/delete' % h.address)
came_from = url('/host/%s/edit' % h.address)
return dict(errors={}, display_name=display_name, action=action,
came_from=came_from)
else:
DBSession.delete(h)
transaction.commit()
flash(_("%s and all associated data have been deleted." % \
_host_address), 'info')
redirect(url('/dashboard'))
示例4: delete
# 需要导入模块: from dmirr.model import DBSession [as 别名]
# 或者: from dmirr.model.DBSession import delete [as 别名]
def delete(self, site_label=None, *a, **kw):
s = DBSession.query(Site).filter_by(label=site_label).first()
_display_name = s.display_name
if not s:
raise HTTPNotFound
_h.protect_obj(s)
confirmed = kw.get('confirmed', None)
if not confirmed:
display_name = s.display_name
action = url('/site/%s/delete' % s.label)
came_from = url('/site/%s/edit' % s.label)
return dict(errors={}, display_name=display_name, action=action,
came_from=came_from)
else:
DBSession.delete(s)
transaction.commit()
flash(_("%s and all associated data have been deleted." % \
_display_name), 'info')
redirect(url('/dashboard'))
示例5: delete
# 需要导入模块: from dmirr.model import DBSession [as 别名]
# 或者: from dmirr.model.DBSession import delete [as 别名]
def delete(self, release_label=None, *a, **kw):
r = DBSession.query(ProductRelease)\
.filter_by(label=release_label)\
.first()
_project_label = r.product.project.label
if not r:
raise HTTPNotFound
_h.protect_obj_modify(r.product.project)
confirmed = kw.get('confirmed', None)
display_name = r.display_name
action = url('/product_release/%s/delete' % r.label)
came_from = url('/project/%s/edit' % _project_label)
if not confirmed:
return dict(page="product_release", errors={}, display_name=display_name, action=action, came_from=came_from)
else:
DBSession.delete(r)
transaction.commit()
flash(_("%s and all associated data have been deleted." % display_name), 'info')
redirect(url('/project/%s/edit' % _project_label))
示例6: unassign_project
# 需要导入模块: from dmirr.model import DBSession [as 别名]
# 或者: from dmirr.model.DBSession import delete [as 别名]
def unassign_project(self, site_id, project_id):
s = DBSession.query(Site).filter_by(id=int(site_id)).first()
p = DBSession.query(Project).filter_by(id=int(project_id)).first()
_h.protect_obj(s)
_h.protect_obj(p)
if not s:
raise HTTPNotFound
if not p:
raise HTTPNotFound
_s_label = s.label
sync_path = DBSession.query(SiteSyncPath).filter_by(site_id=s.id)\
.filter_by(project_id=p.id).first()
if sync_path:
DBSession.delete(sync_path)
s.projects.remove(p)
transaction.commit()
redirect(url("/site/%s/edit#mirrored_projects" % _s_label))