def get(self, restaurant_uid): "TODO: get restaurant uid from the path." logging.info(restaurant_uid) categories = category_logic.get_all_by_restaurant_uid(restaurant_uid) dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid) self.render('restaurant.html', {"categories": json_encoder.encode(categories), "dishes": json_encoder.encode(dishes), "restaurant_uid": restaurant_uid})
def testEncode(self): restaurant = Restaurant(name="test") restaruants = [restaurant, restaurant] self.assertEqual( '[{"logo": null, "name": "test", "uid": null}, {"logo": null, "name": "test", "uid": null}]', json_encoder.encode(restaruants), )
def send_response(self, resp): self.response.headers['Content-Type'] = 'application/json' if isinstance(resp, str): self.response.out.write(resp) return elif isinstance(resp, dict): self.response.out.write(json.dumps(resp)) return self.response.out.write(json_encoder.encode(resp))
def testSerialization(self): restaurant = Restaurant(uid = "uid", name = 'Restaurant') self.assertEqual('{"logo": null, "name": "Restaurant", "uid": "uid"}', json_encoder.encode(restaurant))
def get(self): restaurants = restaurant_logic.get_all() self.render('index.html', { "restaurants": json_encoder.encode(restaurants) })