def edit(request, key): layout = Layout.get(db.Key(key)) form = LayoutForm(request.form, obj=layout) if request.method == "POST" and form.validate(): form.auto_populate(layout) layout.put() # clear depending caches for node in layout.get_affected_nodes(): node.invalidate_cache() if form.save.data is True: return redirect(url_for('nut:layouts/list'), 301) return render_template('app:layouts/form.html', form=form, layout=layout)