def METHOD_NAME(self, user_id, template_id):
    quotas.desktop_create(user_id)
    with app.app_context():
        template = r.table("domains").get(template_id).run(db.conn)
        if not template:
            raise Error("not_found", "Template not found", traceback.format_exc())
        user = r.table("users").get(user_id).run(db.conn)
        if not user:
            raise Error("not_found", "NewNonPersistent: user id not found.")
        group = r.table("groups").get(user["group"]).run(db.conn)
        if not group:
            raise Error("not_found", "NewNonPersistent: group id not found.")
    parent_disk = template["hardware"]["disks"][0]["file"]
    create_dict = template["create_dict"]
    create_dict["hardware"]["disks"] = [
        {"extension": "qcow2", "parent": parent_disk}
    ]
    create_dict = _parse_media_info(create_dict)
    new_desktop = {
        "name": template["name"],
        "description": template["description"],
        "kind": "desktop",
        "user": user_id,
        "username": user["username"],
        "status": "CreatingAndStarting",
        "detail": None,
        "category": user["category"],
        "group": user["group"],
        "xml": None,
        "icon": template["icon"],
        "image": template["image"],
        "server": False,
        "os": template["os"],
        "guest_properties": template["guest_properties"],
        "create_dict": {
            "hardware": create_dict["hardware"],
            "origin": template["id"],
        },
        "hypervisors_pools": template["hypervisors_pools"],
        "allowed": {
            "roles": False,
            "categories": False,
            "groups": False,
            "users": False,
        },
        "accessed": int(time.time()),
        "persistent": False,
        "from_template": template["id"],
    }
    new_desktop = _validate_item("domains", new_desktop)
    with app.app_context():
        if _check(r.table("domains").insert(new_desktop).run(db.conn), "inserted"):
            return new_desktop["id"]
    raise Error(
        "internal_server",
        "Unable to create non persistent desktop",
        traceback.format_exc(),
    )