本文整理汇总了Python中models.Entry.from_json方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.from_json方法的具体用法?Python Entry.from_json怎么用?Python Entry.from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.from_json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import from_json [as 别名]
def post(self):
enforce_key(self)
rawEntries = self.request.get("entries")
entries = json.loads(rawEntries)
for e in Entry.all():
e.delete()
for e in entries:
newEntry = Entry()
newEntry.from_json(e)
newEntry.put()
rawTodos = self.request.get("todos")
todos = json.loads(rawTodos)
for t in ToDo.all():
t.delete()
for t in todos:
newToDo = ToDo()
newToDo.from_json(t)
newToDo.put()
self.response.out.write("Backup successfuly restored.")
示例2: new_entry
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import from_json [as 别名]
def new_entry():
p_id = request.json.get('patient_id')
d_id = request.json.get('doctor_id')
day = request.json.get('day')
if p_id is None or d_id is None:
return jsonify({'error': 'entry lost'}), 400
try:
entry = Entry.from_json({ 'patient_id': p_id,
'doctor_id': d_id,
'day': day})
db.session.add(entry)
db.session.commit()
return jsonify({'entry_id': entry.to_json().get('entry_id')}), 201
except:
return '', 500