def post(self):
     self.response.content_type = "application/json; charset=utf-8"
     user_id = self.request.get('user_id')
     friend_id = self.request.get('friend_id')
     try:
         friendship_from_me = ShourFriend.get_relation(user_id, friend_id)
         friendship_from_you = ShourFriend.get_relation(friend_id, user_id)
         if friendship_from_me:
             ShourFriend.destroy(friendship_from_me)
         if friendship_from_you:
             ShourFriend.destroy(friendship_from_you)
         data = {"message": True}
         json.dump(data, self.response.out, ensure_ascii=False)
     except ShourAppError, e:
         data = {"message": False, "err":e.value}
         json.dump(data, self.response.out, ensure_ascii=False)
 def post(self):
     self.response.content_type = "application/json; charset=utf-8"
     user_id = self.request.get('user_id')
     friend_id = self.request.get('friend_id')
     try:
         users = ShourFriend.is_acceptable(user_id, friend_id)
         ShourFriend.is_duplicate_accept(user_id, friend_id)
         # リクエストされていたデータ
         friend_request = ShourFriend.get_relation(friend_id, user_id)
         # 友人リクエスト承認者の投稿したイベント
         user_events = ShourPost.get_master_event(user_id)
         # 友人リクエスト申請者の投稿したイベント
         friend_events = ShourPost.get_master_event(friend_id)
         # クロスグループトランザクションCross-Group (XG) Transactions有効化
         xg_on = db.create_transaction_options(xg=True)
         db.run_in_transaction_options(xg_on, ShourFriend.accept, users[0], users[1], friend_request, user_events, friend_events)
         data = {"message": True}
         json.dump(data, self.response.out, ensure_ascii=False)
     except ShourAppError, e:
         data = {"message": False, "err":e.value}
         json.dump(data, self.response.out, ensure_ascii=False)