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


Python ExampleModel.get_by_id方法代码示例

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


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

示例1: dispatch_request

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
    def dispatch_request(self):
        if request.method == "POST":

            form = request.get_json()
            example_id = form['example_id']

            if example_id:
                example = ExampleModel.get_by_id( int(example_id) )

                if example:
                    try:
                        example.example_name = form['example_name']
                        example.example_description = form['example_description']

                        example.put()
                        return jsonify(result = {'status':'ok'})

                    except CapabilityDisabledError:
                        return jsonify(result = {'status':'Error to update'})

                else:
                    return jsonify(result = {'status':'NOT item found'})

            else:
                return jsonify(result = {'status':'no example_example send'})

        else:
            return jsonify(result = {'status':'NOT is correct method'})
开发者ID:poxstone,项目名称:appg,代码行数:30,代码来源:admin_list_examples.py

示例2: delete_example

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
def delete_example(example_id):
    """Delete an example object"""
    example = ExampleModel.get_by_id(example_id)
    try:
        example.key.delete()
        flash(u'Example %s successfully deleted.' % example_id, 'success')
        return redirect(url_for('list_examples'))
    except CapabilityDisabledError:
        flash(u'App Engine Datastore is currently in read-only mode.', 'info')
        return redirect(url_for('list_examples'))
开发者ID:qehgt,项目名称:flask-appengine-template,代码行数:12,代码来源:views.py

示例3: delete_example

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
def delete_example(example_id):
    """Delete an example object"""
    example = ExampleModel.get_by_id(example_id)
    try:
        example.delete()
        flash(u"Example %s successfully deleted." % example_id, "success")
        return redirect(url_for("list_examples"))
    except CapabilityDisabledError:
        flash(u"App Engine Datastore is currently in read-only mode.", "info")
        return redirect(url_for("list_examples"))
开发者ID:cenzino,项目名称:vp-gae,代码行数:12,代码来源:views.py

示例4: dispatch_request

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
 def dispatch_request(self, example_id):
     example = ExampleModel.get_by_id(example_id)
     if request.method == "POST":
         try:
             example.key.delete()
             flash(u"Example %s successfully deleted." % example_id, "success")
             return redirect(url_for("list_examples"))
         except CapabilityDisabledError:
             flash(u"App Engine Datastore is currently in read-only mode.", "info")
             return redirect(url_for("list_examples"))
开发者ID:pavelkraleu,项目名称:flask-appengine-template,代码行数:12,代码来源:admin_delete_example.py

示例5: delete_dimension

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
def delete_dimension(dimension_id):
    """Delete an dimension object"""
    dimension = ExampleModel.get_by_id(dimension_id)
    try:
        dimension.key.delete()
        flash(u'Example %s successfully deleted.' % dimension_id, 'success')
        return redirect(url_for('list_dimensions'))
    except CapabilityDisabledError:
        flash(u'App Engine Datastore is currently in read-only mode.', 'info')
        return redirect(url_for('list_dimensions'))
开发者ID:loughnane,项目名称:ta,代码行数:12,代码来源:views.py

示例6: edit_example

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
def edit_example(example_id):
    example = ExampleModel.get_by_id(example_id)
    form = ExampleForm(obj=example)
    if request.method == "POST":
        if form.validate_on_submit():
            example.example_name = form.data.get('example_name')
            example.example_description = form.data.get('example_description')
            example.put()
            flash(u'Example %s successfully saved.' % example_id, 'success')
            return redirect(url_for('list_examples'))
    return render_template('edit_example.html', example=example, form=form)
开发者ID:qehgt,项目名称:flask-appengine-template,代码行数:13,代码来源:views.py

示例7: dispatch_request

# 需要导入模块: from models import ExampleModel [as 别名]
# 或者: from models.ExampleModel import get_by_id [as 别名]
 def dispatch_request(self, example_id):
     example = ExampleModel.get_by_id(example_id)
     if request.method == "POST":
         try:
             example.key.delete()
             cache.clear()
             flash(u'Example %s successfully deleted.' % example_id, 'success')
             return redirect(url_for('list_examples'))
         except CapabilityDisabledError:
             flash(u'App Engine Datastore is currently in read-only mode.', 'info')
             return redirect(url_for('list_examples'))
开发者ID:kamalgill,项目名称:flask-appengine-template,代码行数:13,代码来源:admin_delete_example.py


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