当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.delete方法代码示例

本文整理汇总了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')
    )
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:58,代码来源:views.py

示例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
        )
    )
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:54,代码来源:views.py

示例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)
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:19,代码来源:charts.py

示例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
        )
    )
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:41,代码来源:views.py


注:本文中的sngconnect.database.DBSession.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。