コード例 #1
0
ファイル: pages.py プロジェクト: niczy/hyo
 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})
コード例 #2
0
ファイル: json_encoder_test.py プロジェクト: niczy/hyo
 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),
     )
コード例 #3
0
ファイル: api.py プロジェクト: niczy/hyo
  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))
コード例 #4
0
ファイル: restaurant_test.py プロジェクト: niczy/hyo
 def testSerialization(self):
   restaurant = Restaurant(uid = "uid", name = 'Restaurant')
   self.assertEqual('{"logo": null, "name": "Restaurant", "uid": "uid"}',
       json_encoder.encode(restaurant))
コード例 #5
0
ファイル: pages.py プロジェクト: niczy/hyo
 def get(self):
   restaurants = restaurant_logic.get_all()
   self.render('index.html', {
     "restaurants": json_encoder.encode(restaurants)
     })