本文整理汇总了Python中assembl.models.Idea.db方法的典型用法代码示例。如果您正苦于以下问题:Python Idea.db方法的具体用法?Python Idea.db怎么用?Python Idea.db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assembl.models.Idea
的用法示例。
在下文中一共展示了Idea.db方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_idea
# 需要导入模块: from assembl.models import Idea [as 别名]
# 或者: from assembl.models.Idea import db [as 别名]
def delete_idea(request):
idea_id = request.matchdict['id']
idea = Idea.get_instance(idea_id)
if not idea:
raise HTTPNotFound("Idea with id '%s' not found." % idea_id)
if isinstance(idea, RootIdea):
raise HTTPBadRequest("Cannot delete root idea.")
num_childrens = len(idea.children)
if num_childrens > 0:
raise HTTPBadRequest("Idea cannot be deleted because it still has %d child ideas." % num_childrens)
num_extracts = len(idea.extracts)
if num_extracts > 0:
raise HTTPBadRequest("Idea cannot be deleted because it still has %d extracts." % num_extracts)
db = Idea.db()
db.delete(idea)
request.response.status = HTTPNoContent.code
return HTTPNoContent()