From 01b4ca2535bd25b940c10b1ae1c4706cb33b3619 Mon Sep 17 00:00:00 2001 From: "Zhanwen \"Phil\" Chen" Date: Wed, 1 Feb 2017 21:42:41 -0500 Subject: [PATCH 1/2] Fixed method name duplication Otherwise an AssertionError is raised: "View function mapping is overwriting an existing endpoint function: restaurantMenu" in line 32. --- Lesson-3/12_Edit-Menu-Form/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lesson-3/12_Edit-Menu-Form/project.py b/Lesson-3/12_Edit-Menu-Form/project.py index 1a2b527..c672615 100644 --- a/Lesson-3/12_Edit-Menu-Form/project.py +++ b/Lesson-3/12_Edit-Menu-Form/project.py @@ -13,7 +13,7 @@ @app.route('/') -def restaurantMenu(restaurant_id): +def restaurantMenu_home(restaurant_id): restaurant = session.query(Restaurant).first() items = session.query(MenuItem).filter_by(restaurant_id=restaurant.id) output = '' From 4d679a57085358d2dea161b499abd6368f1e3486 Mon Sep 17 00:00:00 2001 From: "Zhanwen \"Phil\" Chen" Date: Wed, 1 Feb 2017 21:50:46 -0500 Subject: [PATCH 2/2] Deleted "/" routing block It doesn't make sense for that entire block to exist. "/" should do nothing and "restaurantMenu" is a duplicate method that takes a parameter "restaurant_id" which doesn't exist in the "/" routing. --- Lesson-3/12_Edit-Menu-Form/project.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Lesson-3/12_Edit-Menu-Form/project.py b/Lesson-3/12_Edit-Menu-Form/project.py index c672615..10caa78 100644 --- a/Lesson-3/12_Edit-Menu-Form/project.py +++ b/Lesson-3/12_Edit-Menu-Form/project.py @@ -12,23 +12,6 @@ session = DBSession() -@app.route('/') -def restaurantMenu_home(restaurant_id): - restaurant = session.query(Restaurant).first() - items = session.query(MenuItem).filter_by(restaurant_id=restaurant.id) - output = '' - for i in items: - output += i.name - output += '
' - output += i.price - output += '
' - output += i.description - output += '
' - output += '
' - - return output - - @app.route('/restaurants//') def restaurantMenu(restaurant_id): restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one()