def check_send_patch(self, url, patch, next_func):
        # Will send a PATCH request to url with a payload of to_json(patch)
        # Then calls check_new_state to verify that the patch data was actually
        # incorporated.
        if not callable(next_func):
            raise Exception('Was handed non-callable "next_func"')

        def on_response(response):
            eq_(204, response.code)

            self.check_new_state(url, patch, next_func)

        # send a patch off
        req = HTTPRequest(self.get_url(url), 'PATCH',
                          {'Content-Type': 'application/json; charset=UTF-8'},
                          u.to_json(patch))
        self.http_client.fetch(req, on_response)
    def check_send_patch(self, url, patch, next_func):
        # Will send a PATCH request to url with a payload of to_json(patch)
        # Then calls check_new_state to verify that the patch data was actually
        # incorporated.
        if not callable(next_func):
            raise Exception('Was handed non-callable "next_func"')

        def on_response(response):
            eq_(204, response.code)

            self.check_new_state(url, patch, next_func)

        # send a patch off
        req = HTTPRequest(
            self.get_url(url),
            'PATCH',
            {'Content-Type': 'application/json; charset=UTF-8'},
            u.to_json(patch)
        )
        self.http_client.fetch(req, on_response)
Пример #3
0
 def get(self):
     self.set_header('Content-Type', 'application/json; charset=UTF-8')
     self.write(to_json([x.to_json() for x in self.player_state.sessions]))
Пример #4
0
    def get(self):
        self.set_header('Content-Type', 'application/json; charset=UTF-8')

        players = m.RegisteredPlayer.objects.filter(active=True,isvisible=True).order_by('name').values('id','name')
        players = [player_view(self.application, x) for x in players]
        self.write(to_json(players))