def get_data(self, with_view_args=True, is_json=True, copy=False, use_args=False): if is_json: try: data = request.get_json() or {} if use_args: data.update(request.args) except Exception as exc: raise InvalidUsage( _('error decoding json from incoming request')) else: data = request.values data = CombinedMultiDict([data, request.files]) output = {} if copy: # for some reason, following statement doesn't work # output.update(data) # so we have to use following statement for k in data.keys(): output[k] = data[k] if with_view_args: output.update(request.view_args) for key in self.field_names: f = self.field_by_name[key] f.validate(data, output) return output
if field.name in self.field_by_name: raise ValueError, 'a field named \'%s\' already exists' % field.name self.field_names.append(field.name) self.field_by_name[field.name] = field def get_data(self, with_view_args=True, is_json=True, copy=False): if is_json: try: data = request.get_json() or {} except Exception, exc: raise InvalidUsage(_('error decoding json from incoming request')) else: data = request.values data = CombinedMultiDict([data, request.files]) output = {} if copy: # for some reason, following statement doesn't work # output.update(data) # so we have to use following statement for k in data.keys(): output[k] = data[k] if with_view_args: output.update(request.view_args) for key in self.field_names: f = self.field_by_name[key] f.validate(data, output) return output from v1_0 import api_1_0
is_json=True, copy=False, use_args=False): if is_json: try: data = request.get_json() or {} if use_args: data.update(request.args) except Exception, exc: raise InvalidUsage( _('error decoding json from incoming request')) else: data = request.values data = CombinedMultiDict([data, request.files]) output = {} if copy: # for some reason, following statement doesn't work # output.update(data) # so we have to use following statement for k in data.keys(): output[k] = data[k] if with_view_args: output.update(request.view_args) for key in self.field_names: f = self.field_by_name[key] f.validate(data, output) return output from v1_0 import api_1_0