當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。