本文整理汇总了Python中sngconnect.database.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sngconnect.database.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feed_template_delete
# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import delete [as 别名]
def feed_template_delete(request):
try:
feed_template = DBSession.query(FeedTemplate).filter(
FeedTemplate.id == request.matchdict['feed_template_id']
).one()
except database_exceptions.NoResultFound:
raise httpexceptions.HTTPNotFound()
delete_form = forms.DeleteFeedTemplateForm(
feed_template_id=feed_template.id,
csrf_context=request
)
delete_form.process(request.POST)
if delete_form.validate():
dependent_feed_count = DBSession.query(Feed).filter(
Feed.template == feed_template
).count()
dependent_data_stream_template_count = DBSession.query(
DataStreamTemplate
).filter(
DataStreamTemplate.feed_template == feed_template
).count()
if dependent_feed_count > 0:
request.session.flash(
_(
"Device template cannot be deleted as there are"
" already devices based on it. Contact the system"
" support for further information."
),
queue='error'
)
elif dependent_data_stream_template_count > 0:
request.session.flash(
_(
"Device template cannot be deleted as it has parameter"
" templates assigned to it. Contact the system support for"
" further information."
),
queue='error'
)
else:
DBSession.delete(feed_template)
request.session.flash(
_("Device template has been successfully deleted."),
queue='success'
)
else:
request.session.flash(
_(
"There were some problems with your request."
" Contact the system support."
),
queue='error'
)
return httpexceptions.HTTPFound(
request.route_url('sngconnect.devices.feed_templates')
)
示例2: data_stream_template_delete
# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import delete [as 别名]
def data_stream_template_delete(request):
try:
feed_template, data_stream_template = DBSession.query(
FeedTemplate,
DataStreamTemplate
).filter(
FeedTemplate.id == request.matchdict['feed_template_id'],
(DataStreamTemplate.id ==
request.matchdict['data_stream_template_id']),
DataStreamTemplate.feed_template_id == FeedTemplate.id
).one()
except database_exceptions.NoResultFound:
raise httpexceptions.HTTPNotFound()
delete_form = forms.DeleteDataStreamTemplateForm(
data_stream_template_id=data_stream_template.id,
csrf_context=request,
locale=get_locale_name(request)
)
delete_form.process(request.POST)
if delete_form.validate():
dependent_count = DBSession.query(DataStream).filter(
DataStream.template == data_stream_template
).count()
if dependent_count == 0:
DBSession.delete(data_stream_template)
request.session.flash(
_("Parameter template has been successfully deleted."),
queue='success'
)
else:
request.session.flash(
_(
"Parameter template cannot be deleted as there are"
" already parameters based on it. Contact the system"
" support for further information."
),
queue='error'
)
else:
request.session.flash(
_(
"There were some problems with your request."
" Contact the system support."
),
queue='error'
)
return httpexceptions.HTTPFound(
request.route_url(
'sngconnect.devices.feed_template',
feed_template_id=feed_template.id
)
)
示例3: __call__
# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import delete [as 别名]
def __call__(self):
delete_chart_form = forms.DeleteChartDefinitionForm(
csrf_context=self.request
)
delete_chart_form.process(self.request.POST)
if delete_chart_form.validate():
DBSession.delete(self.chart_definition)
return Response(
json.dumps({
'redirect': self.request.route_url(
'sngconnect.telemetry.feed_charts',
feed_id=self.feed.id
),
}),
content_type='application/json'
)
return Response(status_code=400)
示例4: chart_definition_delete
# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import delete [as 别名]
def chart_definition_delete(request):
try:
feed_template, chart_definition = DBSession.query(
FeedTemplate,
ChartDefinition
).filter(
FeedTemplate.id == request.matchdict['feed_template_id'],
(ChartDefinition.id ==
request.matchdict['chart_definition_id']),
ChartDefinition.feed_template_id == FeedTemplate.id,
ChartDefinition.feed == None
).one()
except database_exceptions.NoResultFound:
raise httpexceptions.HTTPNotFound()
delete_form = forms.DeleteChartDefinitionForm(
chart_definition_id=chart_definition.id,
csrf_context=request
)
delete_form.process(request.POST)
if delete_form.validate():
DBSession.delete(chart_definition)
request.session.flash(
_("Chart has been successfully deleted."),
queue='success'
)
else:
request.session.flash(
_(
"There were some problems with your request."
" Contact the system support."
),
queue='error'
)
return httpexceptions.HTTPFound(
request.route_url(
'sngconnect.devices.feed_template',
feed_template_id=feed_template.id
)
)