@mod.route("/<path>/edit/<content_type>/")
def edit_content(path, content_type="Content"):
    path = "/%s/"

    # Get the content type otherwise 404
    try:
        Document = utils.content_type(current_app, content_type)
    except __HOLE__:
        abort(404)
    
    content = Document.objects(path=path).first()

    if content is None:
        content = Document()

    Form = content.admin_form()

    if Form is None:
        abort(404) # We can't edit this content item
    
    form = Form(request.forms, instance=content)

    if request.method == "post" and form.validate():
        doc = form.save()
        redirect(doc.path)

    return render_template("content.html",
                           content=content,
                           admin_form=form)
dataset/ETHPy150Open ericmoritz/flaskcma/flaskcma/content/views.py/edit_content