本文整理汇总了Python中anitya.app.SESSION.delete方法的典型用法代码示例。如果您正苦于以下问题:Python SESSION.delete方法的具体用法?Python SESSION.delete怎么用?Python SESSION.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anitya.app.SESSION
的用法示例。
在下文中一共展示了SESSION.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_distro
# 需要导入模块: from anitya.app import SESSION [as 别名]
# 或者: from anitya.app.SESSION import delete [as 别名]
def delete_distro(distro_name):
""" Delete a distro """
distro = anitya.lib.model.Distro.by_name(SESSION, distro_name)
if not distro:
flask.abort(404)
if not is_admin():
flask.abort(401)
form = anitya.forms.ConfirmationForm()
if form.validate_on_submit():
anitya.log(
SESSION,
distro=distro,
topic='distro.remove',
message=dict(
agent=flask.g.auth.openid,
distro=distro.name,
)
)
SESSION.delete(distro)
SESSION.commit()
flask.flash('Distro %s has been removed' % distro_name)
return flask.redirect(flask.url_for('distros'))
return flask.render_template(
'distro_delete.html',
current='distros',
distro=distro,
form=form)
示例2: delete_project_version
# 需要导入模块: from anitya.app import SESSION [as 别名]
# 或者: from anitya.app.SESSION import delete [as 别名]
def delete_project_version(project_id, version):
project = anitya.lib.model.Project.get(SESSION, project_id)
if not project:
flask.abort(404)
version_obj = None
for vers in project.versions_obj:
if version == vers.version:
version_obj = vers
break
if version_obj is None:
flask.abort(
404,
'Version %s not found for project %s' % (version, project.name)
)
if not is_admin():
flask.abort(401)
form = anitya.forms.ConfirmationForm()
confirm = flask.request.form.get('confirm', False)
if form.validate_on_submit():
if confirm:
anitya.log(
SESSION,
project=project,
topic='project.version.remove',
message=dict(
agent=flask.g.auth.openid,
project=project.name,
version=version,
)
)
# Delete the record of the version for this project
SESSION.delete(version_obj)
# Adjust the latest_version if needed
if project.latest_version == version:
project.latest_version = None
SESSION.add(project)
SESSION.commit()
flask.flash('Version for %s has been removed' % version)
return flask.redirect(
flask.url_for('project', project_id=project.id))
return flask.render_template(
'version_delete.html',
current='projects',
project=project,
version=version,
form=form)
示例3: delete_project_mapping
# 需要导入模块: from anitya.app import SESSION [as 别名]
# 或者: from anitya.app.SESSION import delete [as 别名]
def delete_project_mapping(project_id, distro_name, pkg_name):
project = anitya.lib.model.Project.get(SESSION, project_id)
if not project:
flask.abort(404)
distro = anitya.lib.model.Distro.get(SESSION, distro_name)
if not distro:
flask.abort(404)
package = anitya.lib.model.Packages.get(
SESSION, project.id, distro.name, pkg_name)
if not package:
flask.abort(404)
if not is_admin():
flask.abort(401)
form = anitya.forms.ConfirmationForm()
confirm = flask.request.form.get('confirm', False)
if form.validate_on_submit():
if confirm:
anitya.log(
SESSION,
project=project,
topic='project.map.remove',
message=dict(
agent=flask.g.auth.openid,
project=project.name,
distro=distro.name,
)
)
SESSION.delete(package)
SESSION.commit()
flask.flash('Mapping for %s has been removed' % project.name)
return flask.redirect(
flask.url_for('project', project_id=project.id))
return flask.render_template(
'regex_delete.html',
current='projects',
project=project,
package=package,
form=form)
示例4: delete_project
# 需要导入模块: from anitya.app import SESSION [as 别名]
# 或者: from anitya.app.SESSION import delete [as 别名]
def delete_project(project_id):
project = anitya.lib.model.Project.get(SESSION, project_id)
if not project:
flask.abort(404)
if not is_admin():
flask.abort(401)
project_name = project.name
form = anitya.forms.ConfirmationForm()
confirm = flask.request.form.get('confirm', False)
if form.validate_on_submit():
if confirm:
anitya.log(
SESSION,
project=project,
topic='project.remove',
message=dict(
agent=flask.g.auth.openid,
project=project.name,
)
)
for version in project.versions_obj:
SESSION.delete(version)
SESSION.delete(project)
SESSION.commit()
flask.flash('Project %s has been removed' % project_name)
return flask.redirect(flask.url_for('projects'))
else:
return flask.redirect(
flask.url_for('project', project_id=project.id))
return flask.render_template(
'project_delete.html',
current='projects',
project=project,
form=form)