本文整理汇总了Python中gluon.SQLFORM.confirm方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.confirm方法的具体用法?Python SQLFORM.confirm怎么用?Python SQLFORM.confirm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.confirm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import confirm [as 别名]
def delete():
desk = db.desk(request.args(0))
session.desk_id = desk.id
db.desk.item_list.readable = False
db.desk.item_list.writable = False
form = SQLFORM.confirm(
T("Are you sure?"),
{T('Cancel'): URL('index', args=[desk.id])})
if form.accepted:
# empty move all the items in the desk to the owners desk
for item_id in desk.item_list:
item = db.item(item_id)
owner = db.auth_user(item.created_by)
owner_desk = application.getUserDesk(user=owner)
owner_desk_items = owner_desk.item_list
owner_desk_items.append(item_id)
owner_desk.update_record(item_list=owner_desk_items)
# remove desk from org
org = db(
db.organization.desks.contains(desk.id)
).select().first()
desk_list = org.desks
desk_list.remove(desk.id)
org.update_record(desks=desk_list)
# delete the desk from db.
del db.desk[desk.id]
# cleanup context
session.desk_id = None
# go to org view
redirect(URL('org','view', args=[org.id]))
return locals()