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


Python Db.delete_announce方法代码示例

本文整理汇总了Python中db.Db.delete_announce方法的典型用法代码示例。如果您正苦于以下问题:Python Db.delete_announce方法的具体用法?Python Db.delete_announce怎么用?Python Db.delete_announce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.Db的用法示例。


在下文中一共展示了Db.delete_announce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import delete_announce [as 别名]
def save():
    if not 'username' in session:
        flash('Please log in')
        return redirect(url_for('login'))

    from forms.edit import EditForm
    form = EditForm(request.form, csrf_context=request.remote_addr)

    if form.validate():
        from db import Db
        db = Db()

        if 'delete' in request.form and request.form['delete'] == 'y':
            db.delete_announce(request.form['name'])
            flash('Item succesfully deleted')
        else:
            raw_announces = request.form['texts'].strip()
            announces = {}
            lines = raw_announces.split("\n")

            for line in lines:
                items = line.split("|")
                if len(items) > 1:
                    announces[items[0]] = items[1]

            links = {}
            links['android'] = request.form['android']
            links['ios'] = request.form['ios']


            data = {}
            data['game'] = request.form['name']
            data['announces'] = announces
            data['links'] = links

            if db.update_announce(data) == None:
                flash("Data update error")
            else:
                flash("Data succesfully saved")

        return redirect(url_for('index'))

        #import pprint
        #return pprint.pformat(request.form)
    else:
        flash('Form error! Data wasn\'t saved!')
        return redirect(url_for('index'))
开发者ID:romka,项目名称:announcement-server,代码行数:49,代码来源:ui.py


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