def call_action(self): headers = self.response_headers try: self._authenticate_and_authorize_normal_action() except HTTPException as http_error: response = http_error.description, dict(status=http_error.code) return self._send_response(headers, response) action = camelcase_to_underscores(self._get_action()) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) try: response = method() except HTTPException as http_error: response = http_error.description, dict(status=http_error.code) if isinstance(response, six.string_types): return 200, headers, response else: return self._send_response(headers, response) if not action: return 404, headers, '' raise NotImplementedError( "The {0} action has not been implemented".format(action))
def call_action(self): headers = self.response_headers action = self.querystring.get('Action', [""])[0] if not action: # Some services use a header for the action # Headers are case-insensitive. Probably a better way to do this. match = self.headers.get('x-amz-target') or self.headers.get( 'X-Amz-Target') if match: action = match.split(".")[-1] action = camelcase_to_underscores(action) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) try: response = method() except HTTPException as http_error: response = http_error.description, dict(status=http_error.code) if isinstance(response, six.string_types): return 200, headers, response else: body, new_headers = response status = new_headers.get('status', 200) headers.update(new_headers) return status, headers, body raise NotImplementedError( "The {0} action has not been implemented".format(action))
def call_action(self): headers = self.response_headers action = self.querystring.get('Action', [""])[0] if not action: # Some services use a header for the action # Headers are case-insensitive. Probably a better way to do this. match = self.headers.get( 'x-amz-target') or self.headers.get('X-Amz-Target') if match: action = match.split(".")[-1] action = camelcase_to_underscores(action) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) try: response = method() except HTTPException as http_error: response = http_error.description, dict(status=http_error.code) if isinstance(response, six.string_types): return 200, headers, response else: body, new_headers = response status = new_headers.get('status', 200) headers.update(new_headers) # Cast status to string if "status" in headers: headers['status'] = str(headers['status']) return status, headers, body raise NotImplementedError( "The {0} action has not been implemented".format(action))
def call_action(self): headers = self.response_headers action = camelcase_to_underscores(self._get_action()) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) try: response = method() except HTTPException as http_error: response = http_error.description, dict(status=http_error.code) if isinstance(response, six.string_types): return 200, headers, response else: if len(response) == 2: body, new_headers = response else: status, new_headers, body = response status = new_headers.get('status', 200) headers.update(new_headers) # Cast status to string if "status" in headers: headers['status'] = str(headers['status']) return status, headers, body if not action: return 404, headers, '' raise NotImplementedError( "The {0} action has not been implemented".format(action))
def call_action(self): headers = self.response_headers action = self.querystring.get('Action', [""])[0] action = camelcase_to_underscores(action) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) response = method() if isinstance(response, basestring): return 200, headers, response else: body, new_headers = response status = new_headers.pop('status', 200) headers.update(new_headers) return status, headers, body raise NotImplementedError("The {} action has not been implemented".format(action))
def call_action(self): headers = self.response_headers action = self.querystring.get('Action', [""])[0] action = camelcase_to_underscores(action) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) response = method() if isinstance(response, basestring): return 200, headers, response else: body, new_headers = response status = new_headers.pop('status', 200) headers.update(new_headers) return status, headers, body raise NotImplementedError( "The {} action has not been implemented".format(action))
def dispatch(self, uri, method, body, headers): if body: querystring = parse_qs(body) else: querystring = headers_to_dict(headers) self.path = uri.path self.querystring = querystring action = querystring.get('Action', [""])[0] action = camelcase_to_underscores(action) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) return method() raise NotImplementedError("The {} action has not been implemented".format(action))
def dispatch(self, uri, method, body, headers): if body: querystring = parse_qs(body) else: querystring = parse_qs(headers) action = querystring.get('Action', [None])[0] if action: action = camelcase_to_underscores(action) for sub_response in self.sub_responses: method_names = method_names_from_class(sub_response) if action in method_names: response = sub_response(querystring) method = getattr(response, action) return method() raise NotImplementedError("The {} action has not been implemented".format(action))
def call_action(self): headers = self.response_headers action = self.querystring.get('Action', [""])[0] action = camelcase_to_underscores(action) method_names = method_names_from_class(self.__class__) if action in method_names: method = getattr(self, action) try: response = method() except HTTPException as http_error: response = http_error.description, dict(status=http_error.code) if isinstance(response, six.string_types): return 200, headers, response else: body, new_headers = response status = new_headers.get('status', 200) headers.update(new_headers) return status, headers, body raise NotImplementedError("The {0} action has not been implemented".format(action))