def save(self):
        tmp_path = self.path + '.tmp'
        with open(tmp_path, 'w') as f:
            f.write(json.dumps(self.body_labels.items()))
        os.rename(tmp_path, self.path)
def disable_plugin(plugin):
    try:
        plugin = get_plugin(plugin)
    except KeyError:
        flash(_("Plugin %(plugin)s not found.", plugin=plugin.name), "danger")
        return redirect(url_for("management.plugins"))

    try:
        plugin.disable()
        flash(_("Plugin %(plugin)s disabled. Please restart FlaskBB now.",
                plugin=plugin.name), "success")
    except OSError:
        flash(_("It seems that FlaskBB does not have enough filesystem "
                "permissions. Try creating the 'DISABLED' file by "
                "yourself instead."), "danger")

    return redirect(url_for("management.plugins"))