本文整理汇总了Python中nextgisbio.models.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nextgisbio.models.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_anlist
# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import delete [as 别名]
def delete_anlist(request):
annotation_id = request.matchdict['id']
success = True
try:
with transaction.manager:
dbsession = DBSession()
annotation = dbsession.query(Annotation).filter_by(id=annotation_id).one()
dbsession.delete(annotation)
except:
success = False
return {'success': success}
示例2: delete_card
# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import delete [as 别名]
def delete_card(request):
card_id = request.matchdict['id']
success = True
try:
with transaction.manager:
dbsession = DBSession()
card = dbsession.query(Cards).filter_by(id=card_id).one()
dbsession.delete(card)
except:
success = False
return {'success': success}
示例3: table_delete_jtable
# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import delete [as 别名]
def table_delete_jtable(request):
session = DBSession()
if ('person_id' in request.POST) and request.POST['person_id'].isdigit():
person_id = int(request.POST['person_id'])
person = session.query(Person).options(joinedload('user')).get(person_id)
else:
raise Exception('Deleting item: id is not applied')
session.delete(person)
session.delete(person.user)
transaction.commit()
session.close()
return {
'Result': 'OK'
}
示例4: remove_image
# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import delete [as 别名]
def remove_image(request):
image_id = request.matchdict['image_id']
obj_type = request.matchdict['type']
with transaction.manager:
dbSession = DBSession()
dbSession.query(CardsImages).filter_by(image_id=image_id).delete()
image = dbSession.query(Images).filter_by(id=image_id).one()
if image.local and os.path.exists(image.local):
os.remove(image.local)
path_without_ext, extension = os.path.splitext(image.local)[0], os.path.splitext(image.local)[1]
for key_size in THUMBNAIL_SIZES:
os.remove('%s_%s%s' % (path_without_ext, key_size, extension))
dbSession.delete(image)
return {'success': True}
示例5: table_delete_jtable
# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import delete [as 别名]
def table_delete_jtable(request):
session = DBSession()
table, table_name = helpers.get_table_by_name(request)
if ('id' in request.POST) and request.POST['id'].isdigit():
item_id = int(request.POST['id'])
item = session.query(table).get(item_id)
else:
raise Exception('Deleting item: id is not applied')
session.delete(item)
transaction.commit()
session.close()
return {
'Result': 'OK'
}