def inject_restaurants():
    """This context processor injects the list of restaurants
    into each app.route so that it can be used for the navigation
    menu
    """
    restaurant_list = crud.get_restaurants()
    return dict(restaurant_list=restaurant_list)
def api_restaurants():
    """Returns JSON data for restaurants, and XML if ?type=xml is used"""
    restaurants = crud.get_restaurants()
    if request.args.get('type') == 'xml':
        xml = dicttoxml([i.serialize for i in restaurants], attr_type=False)
        return Response(xml, mimetype='text/xml')
    else:
        return jsonify(Restaurants=[i.serialize for i in restaurants])
def show_restaurants():
    restaurants = crud.get_restaurants()
    return render_template("/restaurants/restaurants.html", restaurants=restaurants)