本文整理汇总了Python中models.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: event_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def event_delete(request):
dbsession = DBSession()
id = clean_matchdict_value(request, 'event')
event = dbsession.query(Event).filter(Event.id == id).one()
dbsession.delete(event)
transaction.commit()
return {'status': 'success'}
示例2: action_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def action_delete(request):
dbsession = DBSession()
name = clean_matchdict_value(request, 'action')
action = dbsession.query(Action).filter(Action.name == name).one()
dbsession.delete(action)
transaction.commit()
return {'status': 'success'}
示例3: team_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def team_delete(request):
dbsession = DBSession()
name = clean_matchdict_value(request, 'team')
entity = dbsession.query(Entity).filter(Entity.name == name).filter(Entity.parent_id == None).one()
dbsession.delete(entity)
transaction.commit()
return {'status': 'success'}
示例4: user_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def user_delete(request):
dbsession = DBSession()
name = clean_matchdict_value(request, 'user')
user = dbsession.query(User).filter(User.name == name).one()
dbsession.delete(user)
transaction.commit()
return {'status': 'success'}
示例5: group_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def group_delete(request):
dbsession = DBSession()
name = clean_matchdict_value(request, 'group')
group = dbsession.query(Group).filter(Group.name == name).one()
dbsession.delete(group)
transaction.commit()
return {'status': 'success'}
示例6: order_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def order_delete(request):
dbsession = DBSession()
name = clean_matchdict_value(request, 'order')
order = dbsession.query(Order).filter(Order.id == id).one()
dbsession.delete(order)
transaction.commit()
return {'status': 'success'}
示例7: delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def delete(self, catid):
session = DBSession()
category = session.query(models.Category).filter_by(id=catid).first()
for item in category.items:
session.delete(item)
session.delete(category)
session.commit()
示例8: entity_type_delete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def entity_type_delete(request):
dbsession = DBSession()
name = clean_matchdict_value(request, 'entity_type')
entity_type = dbsession.query(EntityType).filter(EntityType.name == name).one()
dbsession.delete(entity_type)
transaction.commit()
return {'status': 'success'}
示例9: load_session
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def load_session(sessionid):
session = DBSession.query(Session).filter(Session.sessionid == sessionid).first()
if session and session.expires < datetime.datetime.now():
logging.debug("session %s expired" % (sessionid))
DBSession.delete(session)
return None
else:
return session
示例10: delete_note
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def delete_note(request):
note_id = request.matchdict['note_id']
note = DBSession.query(Note).filter(Note.id == note_id).first()
if request.method == 'POST':
DBSession.delete(note)
request.session.flash(u'Note is successfully deleted', 'success')
return HTTPFound(location=request.route_url('notes'))
return _response_dict(request, note=note)
示例11: delete_pad
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def delete_pad(request):
pad_id = request.matchdict['pad_id']
pad = DBSession.query(Pad).filter(
Pad.id == pad_id,
Pad.user_id == get_current_user(request).id
).first() or raise_404(text='Pad not found')
if request.method == 'POST':
DBSession.delete(pad)
request.session.flash(u'Pad is successfully deleted', 'success')
return HTTPFound(location=request.route_url('notes'))
return _response_dict(request, pad=pad)
示例12: eventDelete
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def eventDelete(request):
eventId = int(request.matchdict['event_id'])
event = DBSession.query(Event).filter(Event.id == eventId).first()
if event == None:
return {'status' : 'Event Not Found'}
DBSession.delete(event)
DBSession.commit()
return {'status' : 'Deleted'}
示例13: delete_picture
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def delete_picture(request):
menu_query = DBSession.query(Menu).filter(Menu.id==request.matchdict['menu_id'])
images_id = menu_query.one().images_id
images_id = images_id.split(' ') if images_id else []
if "data" in request.params:
thumb_url = json.loads(request.params["data"])
image = DBSession.query(Image).filter(Image.thumb_url==thumb_url).filter(Image.id.in_(images_id)).one()
images_id.remove(str(image.id))
images_id = ' '.join([str(i) for i in images_id])
menu_query.update({"images_id": images_id}, synchronize_session=False)
DBSession.delete(image)
return thumb_url
示例14: update_menu_item_allergen
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def update_menu_item_allergen(request):
menu_item_query = DBSession.query(MenuItem).filter(MenuItem.id==request.matchdict['menu_item_id'])
allergen_to_add = request.params.get('menu_item_allergen_on', None)
allergen_to_remove = request.params.get('menu_item_allergen_off', None)
if allergen_to_add:
#create a new allergen for the allergen that's turned on
new_allergen = Allergen(menu_item_id=request.matchdict['menu_item_id'], allergen = allergen_to_add)
DBSession.add(new_allergen)
elif allergen_to_remove:
#delete the allergen that was turned off
allergen_to_remove = DBSession.query(Allergen).filter(Allergen.menu_item_id==request.matchdict['menu_item_id']).filter(Allergen.allergen==allergen_to_remove).one()
DBSession.delete(allergen_to_remove)
menu = DBSession.query(Menu).filter(Menu.id==menu_item_query.one().menu_id).one()
update_gcalendar(menu)
return 'ok'
示例15: forget
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import delete [as 别名]
def forget(request):
"""
Forget the users session/ticket
This removes the users session/ticket entirely, unsets the cookie as well
as removing the ticket from the database.
"""
user = request.user
if user.user is None:
return security.forget(request)
DBSession.delete(user.ticket)
return security.forget(request)