本文整理汇总了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'})
示例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'))
示例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"))
示例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"))
示例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'))
示例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)
示例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'))