Exemplo n.º 1
0
    def test_process_path(self):
        path = '/countries/bra'
        value = args.process_path(path, 'iso')
        self.assertEqual({'iso': 'bra'}, value)

        path = '/countries/bra/123'
        value = args.process_path(path, 'id1')
        self.assertEqual({'iso': 'bra', 'id1': '123'}, value)
Exemplo n.º 2
0
    def get(self):
        try:
            path = self.request.path.strip("/")

            rtype = _classify_request(path)
            # Unsupported dataset or reqest type
            if not rtype:
                self.error(404)
                return

            # Return API meta
            if path == 'countries':
                action, data = self._action_data()
            else:
                path_args = args.process_path(path, rtype)
                action, data = self._action_data(path_args)

            self.complete(action, data)

        except Exception, e:
            logging.exception(e)
            self.write_error(400, e.message)
            self.write(json.dumps(META, sort_keys=True))
Exemplo n.º 3
0
    def get(self):
        try:
            path = self.request.path.strip("/")

            rtype = _classify_request(path)
            # Unsupported dataset or reqest type
            if not rtype:
                self.error(404)
                return

            # Return API meta
            if path == 'countries':
                action, data = self._action_data()
            else:   
                path_args = args.process_path(path, rtype)
                action, data = self._action_data(path_args)

            self.complete(action, data)

        except Exception, e:
            logging.exception(e)
            self.write_error(400, e.message)
            self.write(json.dumps(META, sort_keys=True))