本文整理汇总了Python中alchemist.models.base.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alchemist.models.base.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_connection
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def remove_connection(request):
auth_user = User.bid(request.authenticated_userid)
assert auth_user, 'No user'
conn_id = request.matchdict.get('conn_id')
conn = DBSession.query(Connection).filter(Connection.id == conn_id, Connection.by_user_id == auth_user.id).first()
assert conn, 'You are not authorized to perform this action'
DBSession.delete(conn)
DBSession.flush()
return ''
示例2: vote_to_answer
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def vote_to_answer(request):
aid = request.POST.get('aid', -1)
answer = DBSession.query(Answers).filter(Answers.id == aid).first()
vote = DBSession.query(AnswerVotes).filter(AnswerVotes.answer_id == aid).filter(
AnswerVotes.user_id == request.user.id).first()
if vote is not None:
DBSession.delete(vote)
else:
vote = AnswerVotes(answer=answer, user=request.user)
DBSession.add(vote)
vote_count = DBSession.query(func.count(AnswerVotes.id)).filter(AnswerVotes.answer_id == aid).scalar()
return {'votes': vote_count}
示例3: addto_track
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def addto_track(request):
qid = request.POST.get('qid', -1)
question = DBSession.query(Questions).filter(Questions.id == qid).first()
bookmark_ = (request.POST.get('type') == 'bookmark')
existed = DBSession.query(Trackers).filter(Trackers.questions_id == qid).filter(
Trackers.tracker_id == request.user.id,
Trackers.is_bookmark == bookmark_).first()
if existed:
DBSession.delete(existed)
return {'type': 'removed'}
else:
tracker = Trackers(tracker=request.user, question=question, is_bookmark=bookmark_)
DBSession.add(tracker)
return {'type': 'added'}
示例4: delete_company
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def delete_company(request):
cid = int(request.matchdict.get('id', 0))
should_delete_users = request.matchdict.get('delete_users', '') == 'true'
company = DBSession.query(BaseCompany).filter(BaseCompany.id == cid).first()
resp = 'Deleted %s' % company.name
if should_delete_users:
resp += ' and users: '
deleted_usernames = []
for employee in company.employees:
if should_delete_users:
deleted_usernames.append(employee.nicename)
DBSession.delete(employee)
else:
employee.company = None
if should_delete_users:
resp += ','.join(deleted_usernames)
DBSession.delete(company)
request.session.flash(resp)
return HTTPFound('/')
示例5: delete_unwanted_action
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def delete_unwanted_action(request):
id = request.matchdict.get('id')
unwanted_conn = DBSession.query(UnWanted).filter(UnWanted.id == int(id)).first()
DBSession.delete(unwanted_conn)
return HTTPFound(request.referer)
示例6: tagmanager_delete
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def tagmanager_delete(request):
tag_id = request.matchdict.get('tag_id')
tag = DBSession.query(Tag).filter(Tag.id == int(tag_id)).first()
DBSession.delete(tag)
return HTTPFound(request.referer)
示例7: delete_profile
# 需要导入模块: from alchemist.models.base import DBSession [as 别名]
# 或者: from alchemist.models.base.DBSession import delete [as 别名]
def delete_profile(request):
uid = int(request.matchdict.get('id', 0))
user = User.bid(uid)
DBSession.delete(user)
return HTTPFound('/')